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 XslWithParam extends XslNode { 39 private String _name; 40 private String _select; 41 42 45 public String getTagName() 46 { 47 return "xsl:with-param"; 48 } 49 50 53 public void addAttribute(QName name, String value) 54 throws XslParseException 55 { 56 if (name.getName().equals("name")) 57 _name = value; 58 else if (name.getName().equals("select")) 59 _select = value; 60 else 61 super.addAttribute(name, value); 62 } 63 64 67 public void endAttributes() 68 throws XslParseException 69 { 70 if (_name == null) 71 throw error(L.l("xsl:with-param needs a 'name' attribute.")); 72 } 73 74 77 public void endElement() 78 { 79 addVariableCount(); 80 } 81 82 87 public void generate(JavaWriter out) 88 throws Exception 89 { 90 if (_select != null) { 91 out.print("_exprs[" + addExpr(_select) + "]"); 92 out.println(".addVar(_xsl_arg" + _gen.getCallDepth() + ", \"" + 93 _name + "\", " + 94 "node, env);"); 95 } 96 else { 97 String frag = "_xsl_frag_" + _gen.generateId(); 98 99 out.println("Node " + frag + ";"); 100 101 printFragmentValue(out, frag); 102 103 out.print("_xsl_arg" + _gen.getCallDepth() + ".addVar(\""); 104 out.print(_name); 105 out.println("\", " + frag + ");"); 106 } 107 } 108 } 109 | Popular Tags |