01: package net.sf.saxon.tree;
02:
03: import net.sf.saxon.om.SequenceIterator;
04: import net.sf.saxon.pattern.NodeTest;
05: import net.sf.saxon.type.Type;
06:
07: final class FollowingEnumeration extends TreeEnumeration {
08:
09: private NodeImpl root;
10:
11: public FollowingEnumeration(NodeImpl node, NodeTest nodeTest) {
12: super (node, nodeTest);
13: root = (DocumentImpl) node.getDocumentRoot();
14: // skip the descendant nodes if any
15: int type = node.getNodeKind();
16: if (type == Type.ATTRIBUTE || type == Type.NAMESPACE) {
17: next = ((NodeImpl) node.getParent())
18: .getNextInDocument(root);
19: } else {
20: do {
21: next = (NodeImpl) node.getNextSibling();
22: if (next == null)
23: node = (NodeImpl) node.getParent();
24: } while (next == null && node != null);
25: }
26: while (!conforms(next)) {
27: step();
28: }
29: }
30:
31: protected void step() {
32: next = next.getNextInDocument(root);
33: }
34:
35: /**
36: * Get another enumeration of the same nodes
37: */
38:
39: public SequenceIterator getAnother() {
40: return new FollowingEnumeration(start, nodeTest);
41: }
42:
43: }
44:
45: //
46: // The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
47: // you may not use this file except in compliance with the License. You may obtain a copy of the
48: // License at http://www.mozilla.org/MPL/
49: //
50: // Software distributed under the License is distributed on an "AS IS" basis,
51: // WITHOUT WARRANTY OF ANY KIND, either express or implied.
52: // See the License for the specific language governing rights and limitations under the License.
53: //
54: // The Original Code is: all this file.
55: //
56: // The Initial Developer of the Original Code is Michael H. Kay.
57: //
58: // Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
59: //
60: // Contributor(s): none.
61: //
|