Ticket #99 (closed defect: fixed)

Opened 21 months ago

Last modified 16 months ago

XMLDecl parent and next_sibling methods do not work

Reported by: henrik Owned by: ser
Priority: high Milestone: 3.1.8
Component: DOM Version: 3.1.4
Severity: major Keywords:
Cc: Ruby version: 1.8.5
Operating system: All

Description

For documents with an explicit XML declaration, the parent and next_sibling methods do not work. (It is possible to locate the XML declaration using previous_sibling from the root element.)

This is a problem for programs that use treewalkers or node iterators, like the Test::Unit::Xml framework. The treewalker cannot walk the document tree because it gets stuck on the XML declaration.

The problem is serious because XML declarations are common, and mandatory in XML 1.1.

Attachments

tc_xml_declaration_parent_child.rb (0.9 kB) - added by henrik 21 months ago.
Unit test that fails because of the XML declaration bug

Change History

Changed 21 months ago by henrik

Unit test that fails because of the XML declaration bug

Changed 16 months ago by ser

  • milestone set to 3.1.8

Changed 16 months ago by ser

  • status changed from new to assigned

Changed 16 months ago by ser

  • status changed from assigned to closed
  • resolution set to fixed

Fixed by changeset:1277.

Note that the unit test had to be modified a bit, because the source document contains whitespace text nodes. Text nodes are siblings, so that

    assert_kind_of(REXML::XMLDecl, @root.previous_sibling)
    assert_kind_of(REXML::Element, @xml_declaration.next_sibling)

had to become:

    assert_kind_of(REXML::XMLDecl, @root.previous_sibling.previous_sibling)
    assert_kind_of(REXML::Element, @xml_declaration.next_sibling.next_sibling)

The other thing I could have done was told the parser to ignore whitespace. 6 of one, half-dozen of the other.

Note: See TracTickets for help on using tickets.