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 [email protected] http://rubyforge.org/mailman/listinfo/libxml-devel
a.dtd
Description: Binary data
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE a PUBLIC "-//Test DTDT" "a.dtd" []> <a><b>Testing...</b></a>
require 'xml/libxml'
doc1 = XML::Document.file('dtd.xml')
doc2 = XML::Document.file('nodtd.xml')
node1 = doc1.root.find_first('b')
puts "Node from doc w/ DTD declaration not found" unless node1
node2 = doc2.root.find_first('b')
puts "Node from doc w/o DTD declaration not found" unless node2
unless node1.eql?(node2)
puts "Nodes do not match"
else
puts "Nodes match"
end
puts "NODE1: #{node1}\nNODE2: #{node2}"
<?xml version="1.0" encoding="UTF-8"?> <a><b>Testing...</b></a>
_______________________________________________ libxml-devel mailing list [email protected] http://rubyforge.org/mailman/listinfo/libxml-devel
