1 package net.sf.saxon.tinytree; 2 import net.sf.saxon.om.AxisIteratorImpl; 3 import net.sf.saxon.om.Item; 4 import net.sf.saxon.om.SequenceIterator; 5 import net.sf.saxon.om.NodeInfo; 6 import net.sf.saxon.pattern.NameTest; 7 import net.sf.saxon.pattern.NodeTest; 8 import net.sf.saxon.type.Type; 9 import net.sf.saxon.value.UntypedAtomicValue; 10 import net.sf.saxon.style.StandardNames; 11 12 15 16 final class AttributeEnumeration extends AxisIteratorImpl { 17 18 private TinyTree tree; 19 private int element; 20 private NodeTest nodeTest; 21 private int index; 22 23 31 32 AttributeEnumeration(TinyTree tree, int element, NodeTest nodeTest) { 33 34 this.nodeTest = nodeTest; 35 this.tree = tree; 36 this.element = element; 37 index = tree.alpha[element]; 38 } 39 40 43 44 public Item next() { 45 while (true) { 46 if (index >= tree.numberOfAttributes || tree.attParent[index] != element) { 47 index = Integer.MAX_VALUE; 48 current = null; 49 position = -1; 50 return null; 51 } 52 int typeCode = tree.getAttributeAnnotation(index); 53 if ((typeCode & NodeInfo.IS_DTD_TYPE) != 0) { 54 typeCode = StandardNames.XDT_UNTYPED_ATOMIC; 55 } 56 if (nodeTest.matches(Type.ATTRIBUTE, tree.attCode[index], typeCode)) { 57 position++; 58 int nodeNr = index++; 59 if (nodeTest instanceof NameTest) { 60 index = Integer.MAX_VALUE; 62 } 63 if (isAtomizing() && typeCode == StandardNames.XDT_UNTYPED_ATOMIC) { 64 current = new UntypedAtomicValue(tree.attValue[nodeNr]); 66 return current; 67 } else { 68 current = tree.getAttributeNode(nodeNr); 69 return current; 70 } 71 } 72 index++; 73 } 74 } 75 76 79 80 public SequenceIterator getAnother() { 81 return new AttributeEnumeration(tree, element, nodeTest); 82 } 83 84 } 85 86 87 88 | Popular Tags |