1 28 29 package com.caucho.xsl.java; 30 31 import com.caucho.java.JavaWriter; 32 import com.caucho.xml.QName; 33 import com.caucho.xsl.XslParseException; 34 35 38 public class XslValueOf extends XslNode { 39 private String _select; 40 private String _separator; 41 private String _disableOutputEscaping; 42 43 46 public String getTagName() 47 { 48 return "xsl:value-of"; 49 } 50 51 54 public void addAttribute(QName name, String value) 55 throws XslParseException 56 { 57 if (name.getName().equals("select")) 58 _select = value; 59 else if (name.getName().equals("disable-output-escaping")) 60 _disableOutputEscaping = value; 61 else if (name.getName().equals("separator")) 62 _separator = value; 63 else 64 super.addAttribute(name, value); 65 } 66 67 70 public void endAttributes() 71 throws XslParseException 72 { 73 if (_select == null) 74 throw error(L.l("'select' is a required attribute of <xsl:value-of>")); 75 } 76 77 80 public void addChild(XslNode node) 81 throws XslParseException 82 { 83 throw error(L.l("element <{0}> is not allowed in <{1}>.", 84 node.getTagName(), getTagName())); 85 } 86 87 92 public void generate(JavaWriter out) 93 throws Exception 94 { 95 String var = null; 96 97 if ("yes".equals(_disableOutputEscaping)) { 98 var = "_xsl_out_" + _gen.generateId(); 99 out.println("boolean " + var + " = out.disableEscaping(true);"); 100 } 101 else if ("no".equals(_disableOutputEscaping)) { 102 var = "_xsl_out_" + _gen.generateId(); 103 out.println("boolean " + var + " = out.disableEscaping(false);"); 104 } 105 else if (_disableOutputEscaping != null) 106 throw error(L.l("'{0}' is an unknown value for disable-output-escaping. 'yes' and 'no' are the valid values.", 107 _disableOutputEscaping)); 108 109 printStringExpr(out, _select); 110 111 if (var != null) 112 out.println("out.disableEscaping(" + var + ");"); 113 } 114 } 115 | Popular Tags |