Re: [xslt] xpath queries from shell revisted
- From: Daniel Veillard <veillard redhat com>
- To: The Gnome XSLT library mailing-list <xslt gnome org>
- Subject: Re: [xslt] xpath queries from shell revisted
- Date: Wed, 5 Mar 2008 05:58:39 -0500
On Tue, Mar 04, 2008 at 06:56:01PM +0000, Dan Stromberg wrote:
>
> I'm having a little trouble with some basic XPath queries from shell.
>
> I dug up a small handful of what-seem-like simple examples from http://
> www.w3schools.com/xpath/xpath_syntax.asp and fed them into three xpath
> programs (one in C, one in python, one in perl), and got pretty different
> results from the 3, a number of which I believe must be incorrect.
>
> I've summarized what I found at:
>
> http://stromberg.dnsalias.org/~dstromberg/xml/xpath-issues.html
>
> Is it perhaps the case that some XPath processing programs don't do
> complete xpath? Are there different levels of xpath implementation
> completeness?
I can't debug other implementations. If you have a doubt about libxml2
XPath implementation provide a reproductible test case, with the XML
and how to reproduce the problem with xmllint, textXPath (in the
distribution), xsltproc or a standalone code demonstrating the problem.
There are way you ask the tree to be built which can led to different
results. In that case there is no subtleties, no DTD and libxml2 seems
to just work:
paphio:~/XML -> xmllint --shell tst.xml
/ > xpath bookstore
Object is a Node Set :
Set contains 1 nodes:
1 ELEMENT bookstore
/ > xpath /bookstore
Object is a Node Set :
Set contains 1 nodes:
1 ELEMENT bookstore
/ > xpath bookstore/book
Object is a Node Set :
Set contains 2 nodes:
1 ELEMENT book
2 ELEMENT book
/ > xpath //book
Object is a Node Set :
Set contains 2 nodes:
1 ELEMENT book
2 ELEMENT book
/ > xpath //@lang
Object is a Node Set :
Set contains 2 nodes:
1 ATTRIBUTE lang
TEXT
content=eng
2 ATTRIBUTE lang
TEXT
content=eng
/ >
One thing is sure, if libxml2 XPath implementation was not accurate
for any of the very basic tests you pointed out in that page, well
libxslt/xsltproc which use XPath extensively would be completely
unusable in practice.
Your web page report seems seriously unaccurate just for the fact
that XPath returns programming objects (XPath objects which can be
of various types, all node sets in those queries) and you seems to
just look at *rendering* of those object, plus the embbeding in a
web page, sorry that's not usable for distinguishing what may be
right or wrong. In any case I can't comment or even analyze other
people code.
Daniel
--
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard | virtualization library http://libvirt.org/
veillard redhat com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]