int identity = makeNodeIdentity(nodeHandle); int type; if(identity==DTM.NULL) // Separate lines because I wanted to breakpoint it type = DTM.NULL; else type= _type(identity); if (isTextType(type)) int dataIndex = _dataOrQName(identity); int offset = m_data.elementAt(dataIndex); int length = m_data.elementAt(dataIndex + 1); int firstChild = _firstch(identity); type = _type(identity); if (isTextType(type)) int dataIndex = _dataOrQName(identity); identity = getNextNodeIdentity(identity); } while (DTM.NULL != identity && (_parent(identity) >= startNode)); int dataIndex = _dataOrQName(identity);
addNewDTMID(nodeIndex); setSourceLocation(); declareNamespaceInContext(parentIndex,nodeIndex); break; case DTM.ATTRIBUTE_NODE:
charactersFlush(); String prefix = getPrefix(qName, uri); int prefixIndex = (null != prefix) ? m_valuesOrPrefixes.stringToIndex(qName) : 0; int elemNode = addNode(DTM.ELEMENT_NODE, exName, m_parents.peek(), m_previous, prefixIndex, true); indexNode(exName, elemNode); exName = m_expandedNameTable.getExpandedTypeID(null, prefix, DTM.NAMESPACE_NODE); int val = m_valuesOrPrefixes.stringToIndex(declURL); prev = addNode(DTM.NAMESPACE_NODE, exName, elemNode, prev, val, false); m_pastFirstElement=true; prev = addNode(DTM.NAMESPACE_NODE, exName, elemNode, prev, val, false); prefix = getPrefix(attrQName, attrUri); if (declAlreadyDeclared(prefix)) continue; // go to the next attribute. setIDAttribute(valString, elemNode); prev = addNode(nodeType, exName, elemNode, prev, val, false);
/** * Retrieves an attribute node by by qualified name and namespace URI. * * @param nodeHandle int Handle of the node upon which to look up this attribute.. * @param namespaceURI The namespace URI of the attribute to * retrieve, or null. * @param name The local name of the attribute to * retrieve. * @return The attribute node handle with the specified name ( * <code>nodeName</code>) or <code>DTM.NULL</code> if there is no such * attribute. */ public int getAttributeNode(int nodeHandle, String namespaceURI, String name) { for (int attrH = getFirstAttribute(nodeHandle); DTM.NULL != attrH; attrH = getNextAttribute(attrH)) { String attrNS = getNamespaceURI(attrH); String attrName = getLocalName(attrH); boolean nsMatch = namespaceURI == attrNS || (namespaceURI != null && namespaceURI.equals(attrNS)); if (nsMatch && name.equals(attrName)) return attrH; } return DTM.NULL; }
/** * Determine if the string-value of a node is whitespace * * @param nodeHandle The node Handle. * * @return Return true if the given node is whitespace. */ public boolean isWhitespace(int nodeHandle) { int identity = makeNodeIdentity(nodeHandle); int type; if(identity==DTM.NULL) // Separate lines because I wanted to breakpoint it type = DTM.NULL; else type= _type(identity); if (isTextType(type)) { int dataIndex = _dataOrQName(identity); int offset = m_data.elementAt(dataIndex); int length = m_data.elementAt(dataIndex + 1); return m_chars.isWhitespace(offset, length); } return false; }
int identity = makeNodeIdentity(nodeHandle); int type = _type(identity); int prefixIndex = _dataOrQName(identity); return getPrefix(qname, null); int prefixIndex = _dataOrQName(identity); return getPrefix(qname, null);
dtm = new SAX2DTM(this, source, documentID, whiteSpaceFilter, xstringFactory, doIndexing); dtm.setIncrementalSAXSource(coParser); } catch (RuntimeException re) { dtm.clearCoRoutine(); dtm.clearCoRoutine(); reader.parse(xmlSource); } catch (RuntimeException re) { dtm.clearCoRoutine(); dtm.clearCoRoutine();
charactersFlush(); String prefix = getPrefix(qName, uri); int prefixIndex = (null != prefix) ? m_valuesOrPrefixes.stringToIndex(qName) : 0; int elemNode = addNode(DTM.ELEMENT_NODE, exName, m_parents.peek(), m_previous, prefixIndex, true); exName = m_expandedNameTable.getExpandedTypeID(null, prefix, DTM.NAMESPACE_NODE); int val = m_valuesOrPrefixes.stringToIndex(declURL); prev = addNode(DTM.NAMESPACE_NODE, exName, elemNode, prev, val, false); m_pastFirstElement=true; prev = addNode(DTM.NAMESPACE_NODE, exName, elemNode, prev, val, false); prefix = getPrefix(attrQName, attrUri); if (declAlreadyDeclared(prefix)) continue; // go to the next attribute. setIDAttribute(valString, elemNode); prev = addNode(nodeType, exName, elemNode, prev, val, false);
|| attrQName.startsWith("xmlns:"))) prefix = getPrefix(attrQName, attrUri); if (declAlreadyDeclared(prefix)) continue; // go to the next attribute. setIDAttribute(valString, elemNode);
/** * 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); }
addNewDTMID(nodeIndex); m_maxNodeIndex += (1 << DTMManager.IDENT_DTM_NODE_BITS); setSourceLocation();
/** * Receive notification of the end of the document. * * @throws SAXException Any SAX exception, possibly * wrapping another exception. * @see org.xml.sax.ContentHandler#endDocument */ public void endDocument() throws SAXException { super.endDocument(); // Add a NULL entry to the end of the node arrays as // the end indication. m_exptype.addElement(NULL); m_parent.addElement(NULL); m_nextsib.addElement(NULL); m_firstch.addElement(NULL); // Set the cached references after the document is built. m_extendedTypes = m_expandedNameTable.getExtendedTypes(); m_exptype_map = m_exptype.getMap(); m_nextsib_map = m_nextsib.getMap(); m_firstch_map = m_firstch.getMap(); m_parent_map = m_parent.getMap(); }
/** * Ask the CoRoutine parser to doTerminate and clear the reference. */ public void clearCoRoutine() { clearCoRoutine(true); }
/** * Receive notification of ignorable whitespace in element content. * * <p>By default, do nothing. Application writers may override this * method to take specific actions for each chunk of ignorable * whitespace (such as adding data to a node or buffer, or printing * it to a file).</p> * * @param ch The whitespace characters. * @param start The start position in the character array. * @param length The number of characters to use from the * character array. * @throws SAXException Any SAX exception, possibly * wrapping another exception. * @see org.xml.sax.ContentHandler#ignorableWhitespace */ public void ignorableWhitespace(char ch[], int start, int length) throws SAXException { // %OPT% We can probably take advantage of the fact that we know this // is whitespace. characters(ch, start, length); }
/** * Retrieves an attribute node by by qualified name and namespace URI. * * @param nodeHandle int Handle of the node upon which to look up this attribute.. * @param namespaceURI The namespace URI of the attribute to * retrieve, or null. * @param name The local name of the attribute to * retrieve. * @return The attribute node handle with the specified name ( * <code>nodeName</code>) or <code>DTM.NULL</code> if there is no such * attribute. */ public int getAttributeNode(int nodeHandle, String namespaceURI, String name) { for (int attrH = getFirstAttribute(nodeHandle); DTM.NULL != attrH; attrH = getNextAttribute(attrH)) { String attrNS = getNamespaceURI(attrH); String attrName = getLocalName(attrH); boolean nsMatch = namespaceURI == attrNS || (namespaceURI != null && namespaceURI.equals(attrNS)); if (nsMatch && name.equals(attrName)) return attrH; } return DTM.NULL; }
boolean doStrip = false; if (getShouldStripWhitespace()) int dataIndex = m_data.size(); m_previous = addNode(m_coalescedTextType, exName, m_parents.peek(), m_previous, dataIndex, false);
+ localName + ", qname: "+qName); charactersFlush(); m_nextsib.setElementAt(DTM.NULL,lastNode); popShouldStripWhitespace();
/** * Receive notification of the beginning of the document. * * @throws SAXException Any SAX exception, possibly * wrapping another exception. * @see org.xml.sax.ContentHandler#startDocument */ public void startDocument() throws SAXException { if (DEBUG) System.out.println("startDocument"); int doc = addNode(DTM.DOCUMENT_NODE, m_expandedNameTable.getExpandedTypeID(DTM.DOCUMENT_NODE), DTM.NULL, DTM.NULL, 0, true); m_parents.push(doc); m_previous = DTM.NULL; m_contextIndexes.push(m_prefixMappings.size()); // for the next element. }
/** * Receive notification of the end of the document. * * @throws SAXException Any SAX exception, possibly * wrapping another exception. * @see org.xml.sax.ContentHandler#endDocument */ public void endDocument() throws SAXException { if (DEBUG) System.out.println("endDocument"); charactersFlush(); m_nextsib.setElementAt(NULL,0); if (m_firstch.elementAt(0) == NOTPROCESSED) m_firstch.setElementAt(NULL,0); if (DTM.NULL != m_previous) m_nextsib.setElementAt(DTM.NULL,m_previous); m_parents = null; m_prefixMappings = null; m_contextIndexes = null; m_endDocumentOccured = true; // Bugzilla 4858: throw away m_locator. we cache m_systemId m_locator = null; }
/** * SAX2: Receive notification of character data. */ public void characters(char[] ch, int start, int length) throws SAXException { super.characters(ch, start, length); _disableEscaping = !_escaping; _textNodeToProcess = getNumberOfNodes(); }