/** * Get the current context node. * * @return the <a href="http://www.w3.org/TR/xslt#dt-current-node">current node</a>. */ public final int getCurrentNode() { return m_currentNodes.peek(); }
/** * Get the current node that is the expression's context (i.e. for current() support). * * @return The current sub-expression node. */ public final int getCurrentExpressionNode() { return m_currentExpressionNodes.peek(); }
public final int getPredicatePos() { return m_predicatePos.peek(); }
/** * Get the current context node. * * @return the <a href="http://www.w3.org/TR/xslt#dt-current-node">current node</a>. */ public final int getCurrentNode() { return m_currentNodes.peek(); }
/** * Get the current node that is the expression's context (i.e. for current() support). * * @return The current sub-expression node. */ public final int getCurrentExpressionNode() { return m_currentExpressionNodes.peek(); }
public final int getPredicatePos() { return m_predicatePos.peek(); }
/** * Get a prefix either from the qname or from the uri mapping, or just make * one up! * * @return The prefix if there is one, or null. */ public String getNamespaceURI(String prefix) { String uri = ""; int prefixIndex = m_contextIndexes.peek() - 1 ; if(null == prefix) prefix = ""; do { prefixIndex = m_prefixMappings.indexOf(prefix, ++prefixIndex); } while ( (prefixIndex >= 0) && (prefixIndex & 0x01) == 0x01); if (prefixIndex > -1) { uri = (String) m_prefixMappings.elementAt(prefixIndex + 1); } return uri; }
/** * Get a prefix either from the qname or from the uri mapping, or just make * one up! * * @return The prefix if there is one, or null. */ public String getNamespaceURI(String prefix) { String uri = ""; int prefixIndex = m_contextIndexes.peek() - 1 ; if(null == prefix) prefix = ""; do { prefixIndex = m_prefixMappings.indexOf(prefix, ++prefixIndex); } while ( (prefixIndex >= 0) && (prefixIndex & 0x01) == 0x01); if (prefixIndex > -1) { uri = (String) m_prefixMappings.elementAt(prefixIndex + 1); } return uri; }
/** * Check if a declaration has already been made for a given prefix. * * @param prefix non-null prefix string. * * @return true if the declaration has already been declared in the * current context. */ protected boolean declAlreadyDeclared(String prefix) { int startDecls = m_contextIndexes.peek(); java.util.Vector prefixMappings = m_prefixMappings; int nDecls = prefixMappings.size(); for (int i = startDecls; i < nDecls; i += 2) { String prefixDecl = (String) prefixMappings.elementAt(i); if (prefixDecl == null) continue; if (prefixDecl.equals(prefix)) return true; } return false; }
/** * Check if a declaration has already been made for a given prefix. * * @param prefix non-null prefix string. * * @return true if the declaration has already been declared in the * current context. */ protected boolean declAlreadyDeclared(String prefix) { int startDecls = m_contextIndexes.peek(); java.util.Vector prefixMappings = m_prefixMappings; int nDecls = prefixMappings.size(); for (int i = startDecls; i < nDecls; i += 2) { String prefixDecl = (String) prefixMappings.elementAt(i); if (prefixDecl == null) continue; if (prefixDecl.equals(prefix)) return true; } return false; }
/** * Receive notification of the end of a Namespace mapping. * * <p>By default, do nothing. Application writers may override this * method in a subclass to take specific actions at the end of * each prefix mapping.</p> * * @param prefix The Namespace prefix being declared. * @throws SAXException Any SAX exception, possibly * wrapping another exception. * @see org.xml.sax.ContentHandler#endPrefixMapping */ public void endPrefixMapping(String prefix) throws SAXException { if (DEBUG) System.out.println("endPrefixMapping: prefix: " + prefix); if(null == prefix) prefix = ""; int index = m_contextIndexes.peek() - 1; do { index = m_prefixMappings.indexOf(prefix, ++index); } while ( (index >= 0) && ((index & 0x01) == 0x01) ); if (index > -1) { m_prefixMappings.setElementAt("%@$#^@#", index); m_prefixMappings.setElementAt("%@$#^@#", index + 1); } // no op }
/** * Specialized interface used by DOM2SAX. This one has an extra Node * parameter to build the Node -> id map. */ public void startElement(String uri, String localName, String qname, Attributes attributes, Node node) throws SAXException { this.startElement(uri, localName, qname, attributes); if (m_buildIdIndex) { _node2Ids.put(node, new Integer(m_parents.peek())); } }
/** * Report an XML comment anywhere in the document. * * <p>This callback will be used for comments inside or outside the * document element, including comments in the external DTD * subset (if read).</p> * * @param ch An array holding the characters in the comment. * @param start The starting position in the array. * @param length The number of characters to use from the array. * @throws SAXException The application may raise an exception. */ public void comment(char ch[], int start, int length) throws SAXException { if (m_insideDTD) // ignore comments if we're inside the DTD return; charactersFlush(); // %OPT% Saving the comment string in a Vector has a lower cost than // saving it in DTMStringPool. m_values.addElement(new String(ch, start, length)); int dataIndex = m_valueIndex++; m_previous = addNode(DTM.COMMENT_NODE, DTM.COMMENT_NODE, m_parents.peek(), m_previous, dataIndex, false); }
/** * Report an XML comment anywhere in the document. * * <p>This callback will be used for comments inside or outside the * document element, including comments in the external DTD * subset (if read).</p> * * @param ch An array holding the characters in the comment. * @param start The starting position in the array. * @param length The number of characters to use from the array. * @throws SAXException The application may raise an exception. */ public void comment(char ch[], int start, int length) throws SAXException { if (m_insideDTD) // ignore comments if we're inside the DTD return; charactersFlush(); // %OPT% Saving the comment string in a Vector has a lower cost than // saving it in DTMStringPool. m_values.addElement(new String(ch, start, length)); int dataIndex = m_valueIndex++; m_previous = addNode(DTM.COMMENT_NODE, DTM.COMMENT_NODE, m_parents.peek(), m_previous, dataIndex, false); }
/** * SAX2: Receive notification of the beginning of an element. */ public void startElement(String uri, String localName, String qname, Attributes attributes) throws SAXException { super.startElement(uri, localName, qname, attributes); handleTextEscaping(); if (m_wsfilter != null) { // Look for any xml:space attributes // Depending on the implementation of attributes, this // might be faster than looping through all attributes. ILENE final int index = attributes.getIndex(XMLSPACE_STRING); if (index >= 0) { xmlSpaceDefine(attributes.getValue(index), m_parents.peek()); } } }
/** * Report an XML comment anywhere in the document. * * <p>This callback will be used for comments inside or outside the * document element, including comments in the external DTD * subset (if read).</p> * * @param ch An array holding the characters in the comment. * @param start The starting position in the array. * @param length The number of characters to use from the array. * @throws SAXException The application may raise an exception. */ public void comment(char ch[], int start, int length) throws SAXException { if (m_insideDTD) // ignore comments if we're inside the DTD return; charactersFlush(); int exName = m_expandedNameTable.getExpandedTypeID(DTM.COMMENT_NODE); // For now, treat comments as strings... I guess we should do a // seperate FSB buffer instead. int dataIndex = m_valuesOrPrefixes.stringToIndex(new String(ch, start, length)); m_previous = addNode(DTM.COMMENT_NODE, exName, m_parents.peek(), m_previous, dataIndex, false); }
/** * Report an XML comment anywhere in the document. * * <p>This callback will be used for comments inside or outside the * document element, including comments in the external DTD * subset (if read).</p> * * @param ch An array holding the characters in the comment. * @param start The starting position in the array. * @param length The number of characters to use from the array. * @throws SAXException The application may raise an exception. */ public void comment(char ch[], int start, int length) throws SAXException { if (m_insideDTD) // ignore comments if we're inside the DTD return; charactersFlush(); int exName = m_expandedNameTable.getExpandedTypeID(DTM.COMMENT_NODE); // For now, treat comments as strings... I guess we should do a // seperate FSB buffer instead. int dataIndex = m_valuesOrPrefixes.stringToIndex(new String(ch, start, length)); m_previous = addNode(DTM.COMMENT_NODE, exName, m_parents.peek(), m_previous, dataIndex, false); }
/** * Receive notification of a processing instruction. * * <p>By default, do nothing. Application writers may override this * method in a subclass to take specific actions for each * processing instruction, such as setting status variables or * invoking other methods.</p> * * @param target The processing instruction target. * @param data The processing instruction data, or null if * none is supplied. * @throws SAXException Any SAX exception, possibly * wrapping another exception. * @see org.xml.sax.ContentHandler#processingInstruction */ public void processingInstruction(String target, String data) throws SAXException { if (DEBUG) System.out.println("processingInstruction: target: " + target +", data: "+data); charactersFlush(); int exName = m_expandedNameTable.getExpandedTypeID(null, target, DTM.PROCESSING_INSTRUCTION_NODE); int dataIndex = m_valuesOrPrefixes.stringToIndex(data); m_previous = addNode(DTM.PROCESSING_INSTRUCTION_NODE, exName, m_parents.peek(), m_previous, dataIndex, false); }
/** * Override the processingInstruction() interface in SAX2DTM2. * <p> * %OPT% This one is different from SAX2DTM.processingInstruction() * in that we do not use extended types for PI nodes. The name of * the PI is saved in the DTMStringPool. * * Receive notification of a processing instruction. * * @param target The processing instruction target. * @param data The processing instruction data, or null if * none is supplied. * @throws SAXException Any SAX exception, possibly * wrapping another exception. * @see org.xml.sax.ContentHandler#processingInstruction */ public void processingInstruction(String target, String data) throws SAXException { charactersFlush(); int dataIndex = m_data.size(); m_previous = addNode(DTM.PROCESSING_INSTRUCTION_NODE, DTM.PROCESSING_INSTRUCTION_NODE, m_parents.peek(), m_previous, -dataIndex, false); m_data.addElement(m_valuesOrPrefixes.stringToIndex(target)); m_values.addElement(data); m_data.addElement(m_valueIndex++); }
m_parents.peek(), m_previous, dataIndex, false);