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 XslText extends XslNode { 39 private String _text = ""; 40 private String _disableOutputEscaping; 41 42 45 public void addAttribute(QName name, String value) 46 throws XslParseException 47 { 48 if (name.getName().equals("disable-output-escaping")) 49 _disableOutputEscaping = value; 50 else 51 super.addAttribute(name, value); 52 } 53 54 57 public void addChild(XslNode node) 58 throws XslParseException 59 { 60 if (node == null) 61 return; 62 63 if (node instanceof TextNode) { 64 _text += ((TextNode) node).getText(); 65 } 66 else 67 throw error(L.l("'{0}' is not allowed as an xsl:text child.", 68 node)); 69 } 70 71 76 public void generate(JavaWriter out) 77 throws Exception 78 { 79 String var = null; 80 81 if ("yes".equals(_disableOutputEscaping)) { 82 var = "_xsl_out_" + _gen.generateId(); 83 out.println("boolean " + var + " = out.disableEscaping(true);"); 84 } 85 else if ("no".equals(_disableOutputEscaping)) { 86 var = "_xsl_out_" + _gen.generateId(); 87 out.println("boolean " + var + " = out.disableEscaping(false);"); 88 } 89 else if (_disableOutputEscaping != null) 90 throw error(L.l("'{0}' is an unknown value for disable-output-escaping. 'yes' and 'no' are the valid values.", 91 _disableOutputEscaping)); 92 93 94 out.print("out.print(\""); 95 out.printJavaString(_text); 96 out.println("\");"); 97 98 if (var != null) 99 out.println("out.disableEscaping(" + var + ");"); 100 } 101 } 102 | Popular Tags |