Hi,
I have just committed, to xml-xalan, a prototype implementation of the DOM
L3 XPath Specification.
The interfaces org.w3c.dom.xpath.* are being picked up from xercesImpl.jar.
The implementing classes can be found in the org.apache.xpath.domapi
package. One possible usage would be as follows. There are other
variations, such as using the evaluate method on XPathExpression instead of
XPathEvaluator. (I hope the formatting isn't too terrible...)
// Set up a DOM tree to query.
InputSource in = new InputSource(new FileInputStream(filename));
DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance
();
dfactory.setNamespaceAware(true);
Document doc = dfactory.newDocumentBuilder().parse(in);
// some xpath expression
String xpath = "/";
// pass the document to the XPathEvaluatorImpl constructor to
parallel the case where XPathEvaluator was obtained by casting a document.
XPathEvaluator xpathEvaluator = new
org.apache.xpath.domapi.XPathEvaluatorImpl(doc);
XPathResult result = (XPathResult)xpathEvaluator.evaluate(xpath, doc,
xpathEvaluator.createNSResolver(doc),
XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null);
Node n;
int j = 0;
while (j < result.getSnapshotLength())
{
n = result.snapshotItem(j++);
// do something with node
}
The XPathNamespace node interface has not been implemented (yet?)
Otherwise, it should be reasonably conformant, but it still needs work. I
welcome feedback!
Ilene Seelemann.
------
IBM Toronto Lab
Internet: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]