Hi,

I have just started using libxml2 for ruby and have come to a problem. Attribute traversal is broken. Only the first attr is accessible from .properties.

Here is an illustration:

require 'rubygems'
require 'libxml'
p=XML::Parser.string(%q{<element name="actid" type="xs:positiveInteger"/>})
d=p.parse
irb(main):007:0> d.root.properties
=> name = actid
irb(main):008:0> d.root.properties.next
=> nil

This should yield the "type" attribute.

I have modified the ruby_xml_attr.c and ruby_xml_node.c, the same run yields this:

require 'libxml_so'
p=XML::Parser.string(%q{<element name="actid" type="xs:positiveInteger"/>})
d=p.parse
irb(main):004:0> d.root.properties
=> #<XML::Attr:0x7e888>
irb(main):005:0> d.root.properties.name
=> "name"
irb(main):006:0> d.root.properties.next.name
=> "type"
irb(main):007:0> d.root.properties.next
=> #<XML::Attr:0x67188>
irb(main):009:0> d.root.properties.next.name
=> "type"

The problem seems to be the use of:

  rxa->attr = xmlCopyProp(attr->parent, attr);

xmlCopyProp seems to disconnect attr->next in the copy

In addition to which, I do not know why it would need to copy instead of just use the xmlAttrPtr from the model.

Unless there is some problem with this, here is a patch for it.


Attachment: libxml-ruby-0.3.8.1.patch
Description: Binary data


_______________________________________________
libxml-devel mailing list
libxml-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/libxml-devel

Reply via email to