stoupa91 / eclipse-xpath-evaluation-plugin

Automatically exported from code.google.com/p/eclipse-xpath-evaluation-plugin
4 stars 1 forks source link

'//' not working #4

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. open the attached xml file
2. try e.g. '//table' as expression, returns no results

What is the expected output? What do you see instead?
I would expect the plugin to find the two table nodes that are in the file. 
Pythons lxml library, as well as the notepad++ plugins find the nodes. If I run 
the Eclipse plugin to validate the file it checks out as valid.

What version of the product are you using? On what operating system?
running Indigo with plugin version 1.2.3.201210101856

Additional information:
The attached file was originally a webpage, it was scraped and parsed with 
lxml. The lxml output was written to the file.

Original issue reported on code.google.com by waa...@gmail.com on 20 Jan 2013 at 2:18

Attachments:

GoogleCodeExporter commented 8 years ago
Thanks, for reporting, but I have problem reproducing your issue. When I create 
a simple XML file, "//" works well there. I'm not sure, why it doesn't work 
with your file yet, but I tried to check it in notepad++ and have problem 
evaluating the XPath there. Are you using "XML Tools -> Evaluate XPath 
expression" in notepad++? Please, let me know, so we can narrow down the issue. 
Thx.

Original comment by stoupa91 on 21 Jan 2013 at 5:06

GoogleCodeExporter commented 8 years ago
Ok, I got it. There is "problem" with the declared namespace. For the time 
being you can use any of those two solutions:
1) Remove the namespace from you XML document
2) Let the XPath plugin know about the namespace(s).
   (On the right side of the plugin view declare new namespace with (let's say) Prefix "x" and URI "http://www.w3.org/1999/xhtml" (both without the apostrophes). Then you can use following XPath query "//x:table" and it will find the correct results.)

I will think about more user friendly way to handle namespaces and will see 
what can be done. Thanks for raising up this issue.

Original comment by stoupa91 on 21 Jan 2013 at 5:29

GoogleCodeExporter commented 8 years ago
In Notepad++ I used the XPatherizerNPP plugin.

Sorry for uploading the huge file in the first place. I wanted to test what was 
wrong with the file, but was out of time. You have been much too fast so that I 
could search for the reason myself. ;)

Ok so since the namespace attribute assigns this namespace to all child 
elements, it does not match because it only looks in the global namespace. I 
checked how a few XML libraries handle issue, a few will find the node without 
a namespace, others won't, matching the behavior of your code.

A possibility would be to e.g. have a 'default namespace' field. Quite like 
Saxon XPath two provides a settings for a default namespace.
Or maybe for the really crazy ones a 'ignore namespace' (only use local names) 
options might be viable.

As a sidenode for others reading: XPath has a way of finding the nodes 
regardless of namespace, which is through the use of [local-name()=...]

Original comment by waa...@gmail.com on 21 Jan 2013 at 4:48