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