1 16 19 package org.apache.xalan.transformer; 20 21 import javax.xml.transform.TransformerException ; 22 23 import org.apache.xalan.templates.ElemNumber; 24 import org.apache.xml.dtm.DTM; 25 import org.apache.xpath.NodeSetDTM; 26 import org.apache.xpath.XPathContext; 27 28 35 public class Counter 36 { 37 38 42 static final int MAXCOUNTNODES = 500; 43 44 50 int m_countNodesStartCount = 0; 51 52 55 NodeSetDTM m_countNodes; 56 57 62 int m_fromNode = DTM.NULL; 63 64 67 ElemNumber m_numberElem; 68 69 74 int m_countResult; 75 76 84 Counter(ElemNumber numberElem, NodeSetDTM countNodes) throws TransformerException 85 { 86 m_countNodes = countNodes; 87 m_numberElem = numberElem; 88 } 89 90 101 102 111 int getPreviouslyCounted(XPathContext support, int node) 112 { 113 114 int n = m_countNodes.size(); 115 116 m_countResult = 0; 117 118 for (int i = n - 1; i >= 0; i--) 119 { 120 int countedNode = m_countNodes.elementAt(i); 121 122 if (node == countedNode) 123 { 124 125 m_countResult = i + 1 + m_countNodesStartCount; 128 129 break; 130 } 131 132 DTM dtm = support.getDTM(countedNode); 133 134 if (dtm.isNodeAfter(countedNode, node)) 137 break; 138 } 139 140 return m_countResult; 141 } 142 143 148 int getLast() 149 { 150 151 int size = m_countNodes.size(); 152 153 return (size > 0) ? m_countNodes.elementAt(size - 1) : DTM.NULL; 154 } 155 } 156 | Popular Tags |