Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Good XPath API for Java?

Reply
Thread Tools

Good XPath API for Java?

 
 
JS
Guest
Posts: n/a
 
      06-16-2009
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?

 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      06-16-2009
JS wrote:
> 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.

--

Martin Honnen
http://msmvps.com/blogs/martin_honnen/
 
Reply With Quote
 
 
 
 
Joe Kesselman
Guest
Posts: n/a
 
      06-16-2009
>> 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.)
 
Reply With Quote
 
Philippe Poulard
Guest
Posts: n/a
 
      06-16-2009
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/

--
Cordialement,

///
(. .)
--------ooO--(_)--Ooo--------
| Philippe Poulard |
-----------------------------
http://reflex.gforge.inria.fr/
Have the RefleX !
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
"Memory leak" in javax.xml.xpath.XPath Marvin_123456 Java 4 07-29-2005 03:49 PM
XPath: efficiency in xpath expressions Tjerk Wolterink XML 1 11-13-2004 06:03 PM
Are there any XPath parsers that generate XPath trees? goog XML 0 01-14-2004 01:47 PM
XPath that does not include other XPath Anna XML 0 07-31-2003 07:55 AM
Problem selecting a node with XPATH if attribute value contains backslashes - how to force XPATH string to be treated as literal? Alastair Cameron XML 1 07-08-2003 07:24 PM



Advertisments