Beispiel #1
0
        /// <summary>
        /// Return the result of FollowingAxis expression
        /// </summary>
        /// <param name="node">
        ///            is the type of node. </param>
        public override void iterate(NodeType node, ResultBuffer result, Node limitNode)
        {
            // XXX should be root... not parent!!! read the spec.... BUG BUG
            // BUG LAME LAME....

            if (limitNode != null && limitNode.isSameNode(node.node_value()))
            {
                // no further, we have reached the limit node
                return;
            }

            // get the parent
            NodeType     parent       = null;
            ResultBuffer parentBuffer = new ResultBuffer();

            (new ParentAxis()).iterate(node, parentBuffer, limitNode);
            if (parentBuffer.size() == 1)
            {
                parent = (NodeType)parentBuffer.item(0);
            }

            // get the following siblings of this node, and add them
            FollowingSiblingAxis fsa           = new FollowingSiblingAxis();
            ResultBuffer         siblingBuffer = new ResultBuffer();

            fsa.iterate(node, siblingBuffer, limitNode);

            // for each sibling, get all its descendants
            DescendantAxis da = new DescendantAxis();

            for (IEnumerator i = siblingBuffer.iterator(); i.MoveNext();)
            {
                result.add((NodeType)i);
                da.iterate((NodeType)i.Current, result, null);
            }

            // if we got a parent, we gotta repeat the story for the parent
            // and add the results
            if (parent != null)
            {
                iterate(parent, result, limitNode);
            }
        }