15

i work with Oxygen XMLTester for xPath selectors, supporting XPath 2.0 specification. So i wonder if there is any online tester working with XPath 2.0 spec.? http://www.xmlme.com/XpathTool.aspx[http://www.xmlme.com/XpathTool.aspx][2] http://www.xpathtester.com/test[http://www.xpathtester.com/test][3]

Those above-mentioned testers failed to take the following XPAth (2.0 rather succeded):/list/sum(item/prices/price[@currency='USD']) with XML:

<list>
   <item new='true'>
     <title lang="en">Pop-Music DVD</title>
     <author >K. A. Bred</author>
     <year>2012</year>
     <prices>
       <price currency="USD">29.99</price>
       <price currency="EUR">23.2</price>
     </prices>
   </item>
   <item new='false'>
    <title>Gone with the wind</title>
    <author>M. Mitchell</author>
    <year>1936</year>
    <prices>
      <price currency="USD">19.05</price>
      <price currency="EUR">15</price>
    </prices>
  </item>
</list>
Igor Savinkin
  • 5,669
  • 8
  • 37
  • 69

3 Answers3

30

Since this bubbled up again:

I also made a XPath 2.0 online tester here.

Not so colorful or descriptive, but IMHO easier to use for small queries.

BeniBela
  • 16,412
  • 4
  • 45
  • 52
  • 1
    Fine, except for the fact that it's not XPath 2.0 - I think you should make that clear. – pgfearo Oct 06 '12 at 11:26
  • @pgfearo: What? No, it supports all of XPath 2.0. If there is something it does not support it is a bug, and I will fix it. (or I have already fixed it and just not uploaded, like support for unsigned 64 bit ints or node-name(@attrib).). (at least for now, I'm currently implementing XQuery and then I want to add XPath 3.0, so it might support XPath 3.0 in a few months) – BeniBela Oct 06 '12 at 15:01
  • This is good work, but look up the term 'pseudo' which you're using on your site - it does not give the impression that you're even trying to follow the specification. Be more explicit also about restrictions and extensions - and as a starter, add support for namespaces - even XPath 1.0 supports namespaces. – pgfearo Oct 06 '12 at 17:21
  • @pgfearo: well, when I made the first version of that webpage years ago, it only supported half of XPath 1. And then I have never bothered to update the front end, when I updated the back end. Perhaps I should, but I didn't think anyone would care anyways... And at the bottom of the page are some links to a pasdoc file (that is like javadoc) that lists the major differences. (and it is supposed to be a library for html not xml, in html namespaces are seldom used ) – BeniBela Oct 07 '12 at 09:53
  • Thank you for the XPath 2.0 tester! Great little tool, helped me a lot. – vikingsteve Feb 21 '14 at 07:34
  • Thanks! It worked fine for my needs (html that wouldn't pass strict xml testing) – Henry Apr 07 '14 at 03:18
  • @LarsH: There are no differences for XPath 2.0 anymore in the compatibility mode (at least my code, there are still some issues in the used [regex engine](https://github.com/BeRo1985/flre/issues/10) and XML parser). namespace:: is an XPath 3.0 feature. Actually, namespace:: and the format-* functions are the only XPath 3.0 features it still lacks. Anyways, this was the [pasdoc file](http://www.benibela.de/documentation/internettools/xquery.TXQueryEngine.html). – BeniBela Feb 17 '16 at 23:58
  • The namespace axis was an XPath 1.0 feature (https://www.w3.org/TR/xpath/#axes), but you're right that it's not a required part of XPath 2.0. Thanks, I was not aware of that. – LarsH Feb 18 '16 at 00:34
  • However, `namespace::` is not an XPath 3.0 feature -- it's just as deprecated in 3.0 as in 2.0. (https://www.w3.org/TR/xpath-30/#id-basics) – LarsH Feb 18 '16 at 00:41
  • Then I confused it with the namespace-node test. (I only know the things I have already implemented) – BeniBela Feb 18 '16 at 01:20
  • Great tool, almost perfect – Zoran Jan 21 '18 at 16:58
  • @BeniBela Something is wrong: https://puu.sh/Dfsz6/0ed3e12581.png. It is giving too many results. – dafie Apr 16 '19 at 10:45
  • @dafie: looks as it is repeating parts of output lines 12 to 15. perhaps the merging of the xpath output with the surrounding webpage fails (recently I changed the output buffer, previously it wrote everything on stdout). Does it happen often? I cannot reproduce it – BeniBela Apr 18 '19 at 14:58
5

There's now an online XPath 2.0 tester/analyser at:

http://www.qutoric.com/xslt/analyser/xpathtool.html

This actually runs using the Saxon-CE XSLT 2.0 processor under the covers (the app was written in XSLT 2.0). Screenshot showing your expression evaluated:

enter image description here

pgfearo
  • 2,087
  • 1
  • 22
  • 27
  • Both answers satisfy me for now. – Igor Savinkin Oct 12 '12 at 07:46
  • This is good, although there doesn't seem to be a way to type or paste XML in the browser... it seems that you have to have it in a file. Or am I missing something? Anyway, using Saxon-CE is a great idea, as it gives you a very good quality XSLT/XPath engine in the browser. – LarsH Feb 18 '16 at 01:35
  • You're right, there's no way to add/edit XML in any other way than from a pre-existing file. I wanted to avoid writing another XML editor from scratch (once was enough!) but it could someday be integrated with one of the existing browser-based code editors. – pgfearo Feb 18 '16 at 16:31
1

Here I found useful one more interactive xpath tester.

Amal Murali
  • 75,622
  • 18
  • 128
  • 150
Arup Rakshit
  • 116,827
  • 30
  • 260
  • 317