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 XslIf extends XslNode { 39 private int _test = -1; 40 41 44 public String getTagName() 45 { 46 return "xsl:if"; 47 } 48 49 52 public void addAttribute(QName name, String value) 53 throws XslParseException 54 { 55 if (name.getName().equals("test")) 56 _test = _gen.addExpr(parseExpr(value)); 57 else 58 super.addAttribute(name, value); 59 } 60 61 64 public void endAttributes() 65 throws XslParseException 66 { 67 if (_test < 0) 68 throw error(L.l("xsl:if needs a 'test' attribute.")); 69 } 70 71 76 public void generate(JavaWriter out) 77 throws Exception 78 { 79 out.print("if ("); 80 printExprTest(out, _test, "node"); 81 out.println(") {"); 82 out.pushDepth(); 83 generateChildren(out); 84 out.popDepth(); 85 out.println("}"); 86 } 87 } 88 | Popular Tags |