Good XPath API for Java?

Discussion in 'XML' started by JS, Jun 16, 2009.

  1. JS

    JS Guest

    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?
     
    JS, Jun 16, 2009
    #1
    1. Advertising

  2. 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/
     
    Martin Honnen, Jun 16, 2009
    #2
    1. Advertising

  3. >> 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.)
     
    Joe Kesselman, Jun 16, 2009
    #3
  4. 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 !
     
    Philippe Poulard, Jun 16, 2009
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Marvin_123456

    "Memory leak" in javax.xml.xpath.XPath

    Marvin_123456, Jul 29, 2005, in forum: Java
    Replies:
    4
    Views:
    1,973
    jan V
    Jul 29, 2005
  2. Alastair Cameron
    Replies:
    1
    Views:
    7,412
    SQL Server Development Team [MSFT]
    Jul 8, 2003
  3. Anna
    Replies:
    0
    Views:
    522
  4. goog
    Replies:
    0
    Views:
    508
  5. Tjerk Wolterink

    XPath: efficiency in xpath expressions

    Tjerk Wolterink, Nov 13, 2004, in forum: XML
    Replies:
    1
    Views:
    1,639
    Richard Tobin
    Nov 13, 2004
Loading...

Share This Page