Good XPath API for Java?

js

Usenet Archive
Joined
Aug 20, 2001
Messages
396
Reaction score
0
I am trying to learn XPath and would therefore like to be able to execute various XPath statements on different XML files. I have heard that the best way to do this is to find an XPath API for eg. java and then write some small applications. So far I have been looking at:

http://xml.apache.org/xalan-j/xpath_apis.html

But are there any alternatives that should be considered?
 

Martin Honnen

Usenet Archive
Joined
Apr 8, 2000
Messages
6,174
Reaction score
0
JS said:
I am trying to learn XPath and would therefore like to be able to execute various XPath statements on different XML files. I have heard that the best way to do this is to find an XPath API for eg. java and then write some small applications. So far I have been looking at:

http://xml.apache.org/xalan-j/xpath_apis.html

But are there any alternatives that should be considered?

I am not sure you need to write an application yourself. The jEdit editor for instance has an XSLT/XPath plugin that allows you to evaluate XPath expressions against an XML document. And I am sure that is just an example, there are certainly other tools already providing XPath evaluation.

As for alternatives, if you want to learn and use XPath 1.0 then I think the javax.xml.xpath API is fine but since 2007 we have XPath 2.0 (and XQuery 1.0 of which XPath 2.0 is a subset) so you could consider to use Saxon from http://saxon.sourceforge.net/ to use the more powerful XPath
2.0 or XQuery 1.0 language.
 

Joe Kesselman

Usenet Archive
Joined
Feb 3, 2006
Messages
1,229
Reaction score
0
http://xml.apache.org/xalan-j/xpath_apis.html

Those are essentially the JAXP/TrAX APIs, which are a de facto semi-standard for invoking XPaths from Java... though other implementations may use other APIs.

If you just want to experiment with XPaths, most XPath implementations (including Xalan) come with sample programs which will let you execute an XPath from the command line (or which can easily be tweaked into that form.)

As Martin said, you could also consider finding a tool which supports XPath and using it as your "experimental" environment. I originally learned XPath mostly in the context of using it from XSLT.

Whether you want to jump straight to the 2.0 versions of these depends in part on where you're going to be using them. 2.0 does add a lot of nice features, but it isn't supported everywhere yet (as the Apache code illustrates), so it may be worth considering learning 1.0 first and then adding on the 2.0 changes rather than learning 2.0 and then discovering what has to be trimmed out in a 1.0 environment. And in fact, for the most common uses of XPath, the difference between 1.0 and 2.0 isn't very significant. (That may change as people start using Schema-sensitive paths more often, admittedly.)
 

Philippe Poulard

Usenet Archive
Joined
Dec 20, 2001
Messages
412
Reaction score
0
JS a écrit :
I am trying to learn XPath and would therefore like to be able to execute various XPath statements on different XML files. I have heard that the best way to do this is to find an XPath API for eg. java and then write some small applications. So far I have been looking at:

http://xml.apache.org/xalan-j/xpath_apis.html

But are there any alternatives that should be considered?

Hi,

Jaxen is also a good one:
http://jaxen.codehaus.org/

It is the XPath engine used in RefleX:
http://reflex.gforge.inria.fr/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
548,049
Messages
3,104,243
Members
248,133
Latest member
DujonT

Latest Threads

Top