Feedback: The general problem would appear to be a misunderstanding of the
way _parent[] is used. Frankly, I found it a bit confusing in that indexes 0
and 1 appear wasted (I'm sure that someone will straighten me out regarding
the latter!).

Analysis: A node index for _parent[1] has been mistakenly been pushed into
_stack[] (this contains the indicies of the ancestor nodes for the currently
initialized iterator). This behaviour is easy to observe during runtime with
the enclosed source files:

DIFF
===

--- DOMImpl.java        2001/06/12 13:22:05     1.11
+++ DOMImpl.java        2001/06/29 23:14:42
@@ -1010,7 +1010,7 @@
                _startNode = node;
                _node = ROOTNODE;
                int parent = node;
-               while ((parent = _parent[parent]) >= ROOTNODE) {
+               while ((parent = _parent[parent]) > ROOTNODE) {
                    if (_sp == _stack.length) {
                        final int[] stack = new int[_sp + 4];
                        System.arraycopy(_stack, 0, stack, 0, _sp);

XML
===

<dataset><lump><point/><point/><point/></lump></dataset>

XSL
===

<?xml version='1.0' encoding='utf-8' ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
        <xsl:output method="text" indent="no"/>
        <xsl:template match="/">
                <xsl:for-each select="/dataset/lump/point">
                        <xsl:value-of select="count( preceding::node() )"/>
                </xsl:for-each>
        </xsl:template>
</xsl:stylesheet>

Reply via email to