public DTMAxisIterator getChildren(final int node) { if (_enhancedDOM != null) { return _enhancedDOM.getChildren(node); } else { DTMAxisIterator iterator = _dom.getChildren(node); return iterator.setStartNode(node); } }
public String getCounter() { int result; if (_value != Integer.MIN_VALUE) { // See Errata E24 if (_value == 0) return "0"; else if (Double.isNaN(_value)) return "NaN"; else if (_value < 0 && Double.isInfinite(_value)) return "-Infinity"; else if (Double.isInfinite(_value)) return "Infinity"; else result = (int) _value; } else { int next = _node; result = 0; boolean matchesCount = matchesCount(next); if (!matchesCount) { while ((next = _document.getParent(next)) > END) { if (matchesCount(next)) { break; // found target } if (matchesFrom(next)) { next = END; break; // no target found } } } if (next != END) { int from = next; if (!matchesCount && _hasFrom) { // Target found, but need to check if ancestor matches from while ((from = _document.getParent(from)) > END) { if (matchesFrom(from)) { break; // found from } } } // Have we found ancestor matching from? if (from != END) { _countSiblings.setStartNode(next); do { if (matchesCount(next)) result++; } while ((next = _countSiblings.next()) != END); return formatNumbers(result); } } // If no target found then pass the empty list return formatNumbers(EmptyArray); } return formatNumbers(result); }
/** * Set the start node for this iterator * * @param node The start node * @return A reference to this node iterator */ public DTMAxisIterator setStartNode(int node) { if (_isRestartable) { // KeyIndex iterators are always relative to the root node, so there // is never any point in re-reading the iterator (and we SHOULD NOT). if (_source instanceof KeyIndex && _startNode == DTMDefaultBase.ROOTNODE) { return this; } if (node != _startNode) { _source.setStartNode(_startNode = node); _nodes.clear(); while ((node = _source.next()) != END) { _nodes.add(node); } _nodes.sort(); _nodesSize = _nodes.cardinality(); _current = 0; _lastNext = END; resetPosition(); } } return this; }
/** * Initialize the context values for this expression after it is cloned. * * @param context The XPath runtime context for this transformation. */ public void setRoot(int context, Object environment) { super.setRoot(context, environment); if (m_axis > -1) m_iterator = m_cdtm.getAxisIterator(m_axis); m_iterator.setStartNode(m_context); }