1 50 51 package org.openlaszlo.iv.flash.xml.apache; 52 53 import org.openlaszlo.iv.flash.xml.*; 54 55 import java.util.*; 56 import javax.xml.transform.TransformerException ; 57 58 import org.w3c.dom.*; 59 import org.apache.xpath.*; 60 61 68 public class XPathProcessorImpl implements XPathProcessor { 69 70 78 public Iterator selectNodeList(String expr, Node node) throws TransformerException { 79 final NodeList list = XPathHelper.selectNodeList(new XPathContext(), node, expr); 81 final int n = list.getLength(); 82 return new Iterator() { 83 int cur = 0; 84 public boolean hasNext() { 85 return cur < n; 86 } 87 public Object next() { 88 if( !hasNext() ) throw new NoSuchElementException(); 89 return list.item(cur++); 90 } 91 public void remove() { 92 } 93 }; 94 } 95 96 104 public Node selectSingleNode(String expr, Node node) throws TransformerException { 105 return XPathHelper.selectSingleNode(new XPathContext(), node, expr); 107 } 108 } 109 110 111 112 | Popular Tags |