1 16 17 package org.apache.taglibs.xtags.xpath; 18 19 import java.io.IOException ; 20 import java.util.Iterator ; 21 import java.util.List ; 22 23 import javax.servlet.ServletContext ; 24 import javax.servlet.jsp.JspException ; 25 import javax.servlet.jsp.JspWriter ; 26 import javax.servlet.jsp.PageContext ; 27 import javax.servlet.jsp.tagext.TagSupport ; 28 29 import org.dom4j.DocumentException; 30 import org.dom4j.Node; 31 import org.dom4j.XPath; 32 import org.dom4j.DocumentHelper; 33 import org.dom4j.io.OutputFormat; 34 import org.dom4j.io.XMLWriter; 35 36 40 public class CopyOfTag extends AbstractTag { 41 42 43 private XPath xpath; 44 45 46 public CopyOfTag() { 47 } 48 49 public int doStartTag() throws JspException { 52 return EVAL_BODY_INCLUDE; 53 } 54 55 public int doEndTag() throws JspException { 56 Object input = getInputNodes(); 57 if ( xpath != null ) { 58 input = xpath.selectNodes( input ); 59 } 60 if ( input != null ) { 61 try { 62 XMLWriter writer = TagHelper.getXMLWriter( pageContext, this ); 63 writer.write( input ); 64 } 65 catch (IOException e) { 66 handleException(e); 67 } 68 } 69 return EVAL_PAGE; 70 } 71 72 public void release() { 73 super.release(); 74 xpath = null; 75 } 76 77 80 83 public void setSelect(String select) { 84 if ( select != null && ! select.equals( "." ) ) { 85 xpath = createXPath( select ); 86 } 87 else { 88 xpath = null; 89 } 90 } 91 } 92 | Popular Tags |