1 28 29 package com.caucho.jstl.rt; 30 31 import com.caucho.jsp.PageContextImpl; 32 import com.caucho.log.Log; 33 import com.caucho.xpath.Env; 34 import com.caucho.xpath.Expr; 35 import com.caucho.xpath.XPath; 36 37 import org.w3c.dom.Node ; 38 39 import javax.servlet.jsp.JspException ; 40 import javax.servlet.jsp.JspWriter ; 41 import javax.servlet.jsp.tagext.TagSupport ; 42 import java.util.logging.Level ; 43 import java.util.logging.Logger ; 44 45 public class XmlOutTag extends TagSupport { 46 private static final Logger log = Log.open(XmlOutTag.class); 47 private Expr _select; 48 private boolean _escapeXml = true; 49 50 53 public void setSelect(Expr select) 54 { 55 _select = select; 56 } 57 58 61 public void setEscapeXml(boolean escapeXml) 62 { 63 _escapeXml = escapeXml; 64 } 65 66 69 public int doStartTag() 70 throws JspException 71 { 72 try { 73 PageContextImpl pageContext = (PageContextImpl) this.pageContext; 74 75 JspWriter out = pageContext.getOut(); 76 77 Env env = XPath.createEnv(); 78 env.setVarEnv(pageContext.getVarEnv()); 79 80 Node node = pageContext.getNodeEnv(); 81 82 String value = _select.evalString(node, env); 83 84 env.free(); 85 86 if (_escapeXml) 87 com.caucho.el.Expr.toStreamEscaped(out, value); 88 else 89 out.print(value); 90 } catch (Exception e) { 91 log.log(Level.FINE, e.toString(), e); 92 } 93 94 return SKIP_BODY; 95 } 96 } 97 | Popular Tags |