• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

XPath 2

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

in my application I need to make some queries to an external XML file and I am using XPath.

Java6 (and 7 too) offers support to XPath1.0 but I need to build some complex XPath expressions that only work in XPath 2.

At the moment, this is what I am doing:



What should I use and do if I want to switch to XPath?

Thanks
Marco
 
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you'll need to find an implementation which supports Xpath 2.0 queries.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The Saxon library supports XPath 2.0. I wouldn't hold my breath for either Jaxen or Xalan to support it, not for it to become part of the standard class libraries.
 
Marco Rossi
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying with Saxon but I do not find any good examples...

is it enough to do that?



where XPathFactoryImpl() is net.sf.saxon.xpath.XPathFactoryImpl;

but what about XPathExpression?

 
Ranch Hand
Posts: 734
7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
>I am trying with Saxon but I do not find any good examples...
I can give you a complete working demo with null xml document. It tests xpath 2.0 specific suppoted function. I would expect you say "good". It still takes effort to do test or anything at all for that matter.

[0] Add saxon9j.jar and saxon9.jar and saxon9-xpath.jar. (Or some other version, if applicable.)

[1] Only one specific saxon related import statement you need to add (among other according to need.)

(Not even need if you tolerate writing out the full package.)

[2] This is the method to be called upon in the test program.

 
Marco Rossi
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried to execute an XPath 2.0 Expression and it works.
What I have done is simply (I found this code on another website):



Your way and mine are similar, by the way.

I tried with your implementation and my application works fine too, thanks.

Marco

 
I am displeased. You are no longer allowed to read this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic