List Info

Thread: found issue in xpath tutorial




found issue in xpath tutorial
user name
2006-09-10 23:51:37
Just wanted to know if there are any comments regarding the
patch.

Is it ok to copy data from
result->nodesetval->nodeTab[i]->children->conten
t instead of using function xmlNodeListGetString?

The reason for not using xmlNodeListGetString, is in case of
query such as /hello/world/text(), the function
xmlNodeListGetString returns NULL even though element
/hello/world has data, and the function would work fine if
/hello/world query was used instead.

The patch is a bit more complicated than just using the
direct lookup, such that it finds the first XML_TEXT_NODE,
and gets data from there.


-----Original Message-----
From: Beylin, Alex
Sent: Fri 9/8/2006 6:12 PM
To: xmlgnome.org
Subject: [xml] found issue in xpath tutorial
 
Hello,

 

I think I have found an issue in this tutorial: 
http://xmlsoft.o
rg/tutorial/apd.html

 

I am providing a patch (xpath.c.patch), but not sure if
you'll agree
with it.

 

The call to function xmlNodeListGetString has been removed,
and now
there is a lookup for the value directly in the xmlNode
structure.

 

The reason being, is this query does not work:
"/story/storyinfo[author/id="2"]/author/text()"

 

I updated the sample code to accept the query on the command
line, and
it coredumps with above, because the function
xmlNodeListGetString
returns NULL.  For test, I used xpath.xml document, and ran
this query:

./xpath xpath.xml "/story/storyinfo[author/id="2"]/author/text()"

 

If anyone has any other suggestions as to how the coredump
can befixed,
without modifying the query, as I believe it's valid,
please let me
know.

 

I understand that this query would work:
/story/storyinfo[author/id="2"]/author

But I don't see why valid query such as original should
fail, unless
it's invalid, than please explain why.

 

 

We are coding application calling these API's, and I would
like to know
if my fix to sample program is valid, and could be
incorporated into the
application, or if some other function should be called to
get the value
(maybe actually the function xmlNodeListGetString should be
updated?).

 

 

Thank you.

Alex

 


_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xmlgnome.org
http://mai
l.gnome.org/mailman/listinfo/xml
found issue in xpath tutorial
user name
2006-09-11 00:54:37
On Sun, Sep 10, 2006 at 07:51:37PM -0400, ABeylinaxsone.com wrote:
> Just wanted to know if there are any comments regarding
the patch.

  I may not have time to check patches right now.

> Is it ok to copy data from
result->nodesetval->nodeTab[i]->children->conten
t instead of using function xmlNodeListGetString?

  In XPath specific case that should work fine, i.e. if the
tree was built 
without entities references nor CDATA.

Daniel

-- 
Red Hat Virtualization group http://redhat.com/v
irtualization/
Daniel Veillard      | virtualization library  http://libvirt.org/
veillardredhat.com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ |
Rpmfind RPM search engine  http://rpmfind.net/
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xmlgnome.org
http://mai
l.gnome.org/mailman/listinfo/xml
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )