1 16 17 package org.apache.taglibs.xtags.xpath; 18 19 import java.util.Iterator ; 20 import java.util.List ; 21 22 import javax.servlet.jsp.JspException ; 23 24 import org.dom4j.Node; 25 import org.dom4j.XPath; 26 27 32 public class RemoveTag extends AbstractTag { 33 34 35 private XPath xpath; 36 37 public RemoveTag() { 38 } 39 40 41 public int doStartTag() throws JspException { 44 if ( xpath != null ) { 45 List list = xpath.selectNodes( getInputNodes() ); 46 if ( list != null ) { 47 for ( Iterator iter = list.iterator(); iter.hasNext(); ) { 48 Object value = iter.next(); 49 if ( value instanceof Node ) { 50 Node node = (Node) value; 51 node.detach(); 52 } 53 } 54 } 55 } 56 return SKIP_BODY; 57 } 58 59 public void release() { 60 super.release(); 61 xpath = null; 62 } 63 64 65 68 70 public void setSelect(String select) { 71 this.xpath = createXPath( select ); 72 } 73 74 76 public void setSelectXPath(XPath xpath) { 77 this.xpath = xpath; 78 } 79 80 } 81 | Popular Tags |