Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   XML (http://www.velocityreviews.com/forums/f32-xml.html)
-   -   Good XPath API for Java? (http://www.velocityreviews.com/forums/t688004-good-xpath-api-for-java.html)

JS 06-16-2009 10:00 AM

Good XPath API for Java?
 
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 06-16-2009 11:58 AM

Re: Good XPath API for Java?
 
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/

Joe Kesselman 06-16-2009 12:20 PM

Re: Good XPath API for Java?
 
>> 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 06-16-2009 12:48 PM

Re: Good XPath API for Java?
 
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 !


All times are GMT. The time now is 03:47 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.