XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Klarinda GWSubject: XPath parser in Java
Author: Klarinda GW
Date: 10 Oct 2006 12:52 AM
Originally Posted: 09 Oct 2006 05:17 AM
Hi,

Is there any XPath parser written in java?

But I do not want the XPath parser to evaluate the XPath expression
and return the XML nodes (I don't want the XPath parser to query the
XML document). Rather, I want the XPath parser to return an array or a
list or tree or anything where I can traverse step by step.

I am looking for something like this:
xpath = XPathParser.parse("/a/b[P and Q]/following::*[2]");

xpath.step(1) will return axis = child, NameTest = a
xpath.step(2) will return axis = child, NameTest = b, predicate = P and Q
predicate can further be divided into predicate.part(1) = P,
predicate.part(2) = Q, predicate.boolean() = and
(P and Q can be something such as xyz = 'some value' or XPath function)
xpath.step(3) will return axis = following, NameTest = *, predicate = 2


Thanks,

Klarinda

Postnext
David LeeSubject: XPath parser in Java
Author: David Lee
Date: 19 Oct 2006 11:53 AM
Originally Posted: 19 Oct 2006 11:49 AM
Using Saxon you can do this step by step, but not by giving the full expression. Rather you give each sub expression then the results can be converted into a document source which you can then execute the next step on.

like (very abstractly,its a tad more complictated then this)

"a/b/c" ->

s1 = doc.query("a");
s2 = s1.query("b");
s3 = s2.query("c");


I've used this to selectively parse out a big XML file into smaller components which I then pass to other methods which parse further, all using xpath.

Posttop
David LeeSubject: XPath parser in Java
Author: David Lee
Date: 19 Oct 2006 11:54 AM
Rereading the original query, I think my suggestion is not what your looking for. Your trying to parse the syntax of XPath not execute it.

However maybe you can find what your looking for inside saxon source code.

 
Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.