bug-classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug xml/27864] New: Wrong number of entries returned for getElementsByT


From: thebohemian at gmx dot net
Subject: [Bug xml/27864] New: Wrong number of entries returned for getElementsByTagName() in special case
Date: 1 Jun 2006 16:21:26 -0000

Consider this piece of XML:

<main>
        <element>
                <alwaysThere/>
        </element>
        <element>
                <alwaysThere>
                <sometimesThere>foo</sometimesThere>
                </alwaysThere>
        </element>
        <element>
                <alwaysThere>
                <sometimesThere>bar</sometimesThere>
                </alwaysThere>
        </element>
</main>

Reach the <alwaysThere> tag inside the first <element> tag:

doc = DocumentBuildFactory.blafoobaz.parse(theStuffFromAbove);
elem0 = doc.getElementsByTagName("element").item(0);
at = elem0.getElementsByTagName("alwaysThere").item(0);

Now retrieve the children of this element which have the tagname
'sometimesThere':

st_nodes = at.getElementsByTagName("sometimesThere");

Although there are no <sometimesThere> children in the <alwaysThere> element
the list says, there are:

st_nodes.getLength() will return 2.
st_nodes.item(0) and st_nodes().item(1) will turn out to be the
<sometimesThere> elements inside the 2nd and 3rd <element> tag.

By investigating this problem I found out that the reason lies inside the
gnu.xml.dom.DomIterator which does not properly stop iterating (forward) when
the root element is exceeded.

I will provide a mauve test and probably have a fix for it, too.


-- 
           Summary: Wrong number of entries returned for
                    getElementsByTagName() in special case
           Product: classpath
           Version: 0.92
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: xml
        AssignedTo: thebohemian at gmx dot net
        ReportedBy: thebohemian at gmx dot net


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27864





reply via email to

[Prev in Thread] Current Thread [Next in Thread]