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
_______________________________________________
Bug-classpath mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-classpath