[libxml-devel] Specifying namespace on XPath?
Paul Dlug
paul at aps.org
Tue Nov 27 10:42:26 EST 2007
I think I have a related bug that your patch doesn't fix. If I have a
document with a DTD declaration specifying a namespace and an
identical document without it the XPath expression finds the node in
the document w/o DTD but not with the DTD. The attached test case
illustrates the problem, to replicate:
1) Run dtdtest.rb, you will see that the test will fail being unable
to find a node via XML::Node.find()
2) Comment out the ATTLIST spec in a.dtd and re-run, test will pass
this time (or remove the DTD declaration from the file dtd.xml).
--Paul
On Nov 27, 2007, at 8:39 AM, keisuke fukuda wrote:
> So, this should be the patch.
>
> Index: ext/xml/ruby_xml_xpath.c
> ===================================================================
> --- ext/xml/ruby_xml_xpath.c (revision 218)
> +++ ext/xml/ruby_xml_xpath.c (working copy)
> @@ -76,9 +76,9 @@
> }
> else {
> // tuples of prefix/uri
> - if (RARRAY(RARRAY(nslist)->ptr[i])->len == 2) {
> - rprefix = RARRAY(RARRAY(nslist)->ptr[i])->ptr[0];
> - ruri = RARRAY(RARRAY(nslist)->ptr[i])->ptr[1];
> + if (RARRAY(nslist)->len == 2) {
> + rprefix = RARRAY(nslist)->ptr[0];
> + ruri = RARRAY(nslist)->ptr[1];
> ruby_xml_xpath_context_register_namespace(xxpc, rprefix, ruri);
> } else {
> rb_raise(rb_eArgError, "nested array must be an array of
> strings, prefix and href/uri");
> <
> xpath_ns_fix.patch.txt>_______________________________________________
> libxml-devel mailing list
> libxml-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/libxml-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: a.dtd
Type: application/octet-stream
Size: 143 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/libxml-devel/attachments/20071127/3492d043/attachment.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dtd.xml
Type: text/xml
Size: 110 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/libxml-devel/attachments/20071127/3492d043/attachment.xml
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dtdtest.rb
Type: text/x-ruby-script
Size: 420 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/libxml-devel/attachments/20071127/3492d043/attachment.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: nodtd.xml
Type: text/xml
Size: 64 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/libxml-devel/attachments/20071127/3492d043/attachment-0001.xml
-------------- next part --------------
More information about the libxml-devel
mailing list