1 28 29 package com.caucho.jsp.java; 30 31 import com.caucho.jsp.JspParseException; 32 import com.caucho.vfs.WriteStream; 33 import com.caucho.xml.QName; 34 35 import java.io.IOException ; 36 37 40 public class JstlXmlWhen extends JstlNode { 41 private static final QName SELECT = new QName("select"); 42 43 private String _select; 44 45 48 public void addAttribute(QName name, String value) 49 throws JspParseException 50 { 51 if (SELECT.equals(name)) 52 _select = value; 53 else 54 throw error(L.l("`{0}' is an unknown attribute for <{1}>.", 55 name.getName(), getTagName())); 56 } 57 58 61 public void addAttribute(QName name, JspAttribute value) 62 throws JspParseException 63 { 64 if (false) 65 throw error(L.l("`{0}' is an unknown jsp:attribute for <{1}>.", 66 name.getName(), getTagName())); 67 } 68 69 74 public void printXml(WriteStream os) 75 throws IOException 76 { 77 os.print("<x:when select=\""); 78 printXmlText(os, _select); 79 os.print("\">"); 80 81 printXmlChildren(os); 82 83 os.print("</x:when>"); 84 } 85 86 89 public void generate(JspJavaWriter out) 90 throws Exception 91 { 92 if (_select == null) 93 throw error(L.l("required attribute `select' missing from <{0}>", 94 getTagName())); 95 96 97 String ifExpr = ("com.caucho.jstl.el.XmlIfTag.evalBoolean(pageContext, " + 98 _gen.addXPathExpr(_select, getNamespaceContext()) + ")"); 99 100 101 out.println("if (" + ifExpr + ") {"); 102 out.pushDepth(); 103 104 generateChildren(out); 105 106 out.popDepth(); 107 out.println("}"); 108 } 109 } 110 | Popular Tags |