📄 adddefs.java
字号:
/* AddDefs is an example of a class to be called by an
XML ProcessingInstruction, e.g. by MyNa.xml.EchoAsHtml
but it is not itself aware of XML in any way. For example,
the following processing instruction would, if interpreted
by EchoAsHtml, define the XML tag "urp" as the output HTML
tag "ul"; it would also output a string containing some
explicit html codes and two strings (one name and one boolean)
from the environment.
<? MyNa.utils.AddDefs urp
ul
echo_outputlist
<h1>Parser:,echo_parserName,</h1><h2>validate=,echo_validation,</h2>
*/
package MyNa.utils;
import java.io.*;
public class AddDefs {
public AddDefs(String data,Env defs)throws ParseSubstException{
StringReader sr=new StringReader(data);
BufferedReader brin=new BufferedReader(sr);
defs.addBufferedReader(brin);
String nameListStr=defs.getStr("echo_outputlist");
if(null==nameListStr)return;
String[]nameList=Misc.stringSplit(nameListStr,',');
defs.remove("echo_outputlist"); // output only once.
PrintWriter out=(PrintWriter)defs.get("echo_out");
if(null==out)
throw new ParseSubstException("no output stream");
for(int i=0;i<nameList.length;i++){
String val=defs.getStr(nameList[i]);
if(null==val)out.print(nameList[i]);
else out.print(val);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -