Java Code Examples for com.sun.org.apache.xml.internal.dtm.DTM#NAMESPACE_NODE
The following examples show how to use
com.sun.org.apache.xml.internal.dtm.DTM#NAMESPACE_NODE .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SAXImpl.java From Bytecoder with Apache License 2.0 | 6 votes |
/** * Returns the name of a node (attribute or element). */ public String getNodeName(final int node) { // Get the node type and make sure that it is within limits int nodeh = node; final short type = getNodeType(nodeh); switch(type) { case DTM.ROOT_NODE: case DTM.DOCUMENT_NODE: case DTM.TEXT_NODE: case DTM.COMMENT_NODE: return EMPTYSTRING; case DTM.NAMESPACE_NODE: return this.getLocalName(nodeh); default: return super.getNodeName(nodeh); } }
Example 2
Source File: SAX2DTM2.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * The optimized version of DTMDefaultBase.getNextAttributeIdentity(int). * <p> * Given a node identity for an attribute, advance to the next attribute. * * @param identity int identity of the attribute node. This * <strong>must</strong> be an attribute node. * * @return int DTM node-identity of the resolved attr, * or DTM.NULL to indicate none exists. * */ protected int getNextAttributeIdentity(int identity) { // Assume that attributes and namespace nodes immediately follow the element while (true) { identity++; int type = _type2(identity); if (type == DTM.ATTRIBUTE_NODE) { return identity; } else if (type != DTM.NAMESPACE_NODE) { break; } } return DTM.NULL; }
Example 3
Source File: SAX2DTM2.java From Bytecoder with Apache License 2.0 | 5 votes |
/** * The optimized version of DTMDefaultBase.getFirstAttribute(). * <p> * Given a node handle, get the index of the node's first attribute. * * @param nodeHandle int Handle of the node. * @return Handle of first attribute, or DTM.NULL to indicate none exists. */ public final int getFirstAttribute(int nodeHandle) { int nodeID = makeNodeIdentity(nodeHandle); if (nodeID == DTM.NULL) return DTM.NULL; int type = _type2(nodeID); if (DTM.ELEMENT_NODE == type) { // Assume that attributes and namespaces immediately follow the element. while (true) { nodeID++; // Assume this can not be null. type = _type2(nodeID); if (type == DTM.ATTRIBUTE_NODE) { return makeNodeHandle(nodeID); } else if (DTM.NAMESPACE_NODE != type) { break; } } } return DTM.NULL; }
Example 4
Source File: SAX2DTM.java From Bytecoder with Apache License 2.0 | 5 votes |
/** * Given a node handle, return its DOM-style node name. This will * include names such as #text or #document. * * @param nodeHandle the id of the node. * @return String Name of this node, which may be an empty string. * %REVIEW% Document when empty string is possible... * %REVIEW-COMMENT% It should never be empty, should it? */ public String getNodeName(int nodeHandle) { int expandedTypeID = getExpandedTypeID(nodeHandle); // If just testing nonzero, no need to shift... int namespaceID = m_expandedNameTable.getNamespaceID(expandedTypeID); if (0 == namespaceID) { // Don't retrieve name until/unless needed // String name = m_expandedNameTable.getLocalName(expandedTypeID); int type = getNodeType(nodeHandle); if (type == DTM.NAMESPACE_NODE) { if (null == m_expandedNameTable.getLocalName(expandedTypeID)) return "xmlns"; else return "xmlns:" + m_expandedNameTable.getLocalName(expandedTypeID); } else if (0 == m_expandedNameTable.getLocalNameID(expandedTypeID)) { return m_fixednames[type]; } else return m_expandedNameTable.getLocalName(expandedTypeID); } else { int qnameIndex = m_dataOrQName.elementAt(makeNodeIdentity(nodeHandle)); if (qnameIndex < 0) { qnameIndex = -qnameIndex; qnameIndex = m_data.elementAt(qnameIndex); } return m_valuesOrPrefixes.indexToString(qnameIndex); } }
Example 5
Source File: SAX2DTM.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Given a node handle, return its DOM-style node name. This will * include names such as #text or #document. * * @param nodeHandle the id of the node. * @return String Name of this node, which may be an empty string. * %REVIEW% Document when empty string is possible... * %REVIEW-COMMENT% It should never be empty, should it? */ public String getNodeName(int nodeHandle) { int expandedTypeID = getExpandedTypeID(nodeHandle); // If just testing nonzero, no need to shift... int namespaceID = m_expandedNameTable.getNamespaceID(expandedTypeID); if (0 == namespaceID) { // Don't retrieve name until/unless needed // String name = m_expandedNameTable.getLocalName(expandedTypeID); int type = getNodeType(nodeHandle); if (type == DTM.NAMESPACE_NODE) { if (null == m_expandedNameTable.getLocalName(expandedTypeID)) return "xmlns"; else return "xmlns:" + m_expandedNameTable.getLocalName(expandedTypeID); } else if (0 == m_expandedNameTable.getLocalNameID(expandedTypeID)) { return m_fixednames[type]; } else return m_expandedNameTable.getLocalName(expandedTypeID); } else { int qnameIndex = m_dataOrQName.elementAt(makeNodeIdentity(nodeHandle)); if (qnameIndex < 0) { qnameIndex = -qnameIndex; qnameIndex = m_data.elementAt(qnameIndex); } return m_valuesOrPrefixes.indexToString(qnameIndex); } }
Example 6
Source File: SAXImpl.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
/** * Performs a shallow copy (ref. XSLs copy()) */ public String shallowCopy(final int node, SerializationHandler handler) throws TransletException { int nodeID = makeNodeIdentity(node); int exptype = _exptype2(nodeID); int type = _exptype2Type(exptype); try { switch(type) { case DTM.ELEMENT_NODE: final String name = copyElement(nodeID, exptype, handler); copyNS(nodeID, handler, true); return name; case DTM.ROOT_NODE: case DTM.DOCUMENT_NODE: return EMPTYSTRING; case DTM.TEXT_NODE: copyTextNode(nodeID, handler); return null; case DTM.PROCESSING_INSTRUCTION_NODE: copyPI(node, handler); return null; case DTM.COMMENT_NODE: handler.comment(getStringValueX(node)); return null; case DTM.NAMESPACE_NODE: handler.namespaceAfterStartElement(getNodeNameX(node), getNodeValue(node)); return null; case DTM.ATTRIBUTE_NODE: copyAttribute(nodeID, exptype, handler); return null; default: final String uri1 = getNamespaceName(node); if (uri1.length() != 0) { final String prefix = getPrefix(node); handler.namespaceAfterStartElement(prefix, uri1); } handler.addAttribute(getNodeName(node), getNodeValue(node)); return null; } } catch (Exception e) { throw new TransletException(e); } }
Example 7
Source File: DOM2DTM.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
/** * 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) { // %OPT% This is probably slower than it needs to be. if (null == namespaceURI) namespaceURI = ""; int type = getNodeType(nodeHandle); if (DTM.ELEMENT_NODE == type) { // Assume that attributes immediately follow the element. int identity = makeNodeIdentity(nodeHandle); while (DTM.NULL != (identity = getNextNodeIdentity(identity))) { // Assume this can not be null. type = _type(identity); // %REVIEW% // Should namespace nodes be retrievable DOM-style as attrs? // If not we need a separate function... which may be desirable // architecturally, but which is ugly from a code point of view. // (If we REALLY insist on it, this code should become a subroutine // of both -- retrieve the node, then test if the type matches // what you're looking for.) if (type == DTM.ATTRIBUTE_NODE || type==DTM.NAMESPACE_NODE) { Node node = lookupNode(identity); String nodeuri = node.getNamespaceURI(); if (null == nodeuri) nodeuri = ""; String nodelocalname = node.getLocalName(); if (nodeuri.equals(namespaceURI) && name.equals(nodelocalname)) return makeNodeHandle(identity); } else // if (DTM.NAMESPACE_NODE != type) { break; } } } return DTM.NULL; }
Example 8
Source File: SAXImpl.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
private final void copy(final int node, SerializationHandler handler, boolean isChild) throws TransletException { int nodeID = makeNodeIdentity(node); int eType = _exptype2(nodeID); int type = _exptype2Type(eType); try { switch(type) { case DTM.ROOT_NODE: case DTM.DOCUMENT_NODE: for(int c = _firstch2(nodeID); c != DTM.NULL; c = _nextsib2(c)) { copy(makeNodeHandle(c), handler, true); } break; case DTM.PROCESSING_INSTRUCTION_NODE: copyPI(node, handler); break; case DTM.COMMENT_NODE: handler.comment(getStringValueX(node)); break; case DTM.TEXT_NODE: boolean oldEscapeSetting = false; boolean escapeBit = false; if (_dontEscape != null) { escapeBit = _dontEscape.getBit(getNodeIdent(node)); if (escapeBit) { oldEscapeSetting = handler.setEscaping(false); } } copyTextNode(nodeID, handler); if (escapeBit) { handler.setEscaping(oldEscapeSetting); } break; case DTM.ATTRIBUTE_NODE: copyAttribute(nodeID, eType, handler); break; case DTM.NAMESPACE_NODE: handler.namespaceAfterStartElement(getNodeNameX(node), getNodeValue(node)); break; default: if (type == DTM.ELEMENT_NODE) { // Start element definition final String name = copyElement(nodeID, eType, handler); //if(isChild) => not to copy any namespaces from parents // else copy all namespaces in scope copyNS(nodeID, handler,!isChild); copyAttributes(nodeID, handler); // Copy element children for (int c = _firstch2(nodeID); c != DTM.NULL; c = _nextsib2(c)) { copy(makeNodeHandle(c), handler, true); } // Close element definition handler.endElement(name); } // Shallow copy of attribute to output handler else { final String uri = getNamespaceName(node); if (uri.length() != 0) { final String prefix = getPrefix(node); handler.namespaceAfterStartElement(prefix, uri); } handler.addAttribute(getNodeName(node), getNodeValue(node)); } break; } } catch (Exception e) { throw new TransletException(e); } }
Example 9
Source File: NodeTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
/** * Tell what node type to test, if not DTMFilter.SHOW_ALL. * * @param whatToShow Bit set defined mainly by * {@link com.sun.org.apache.xml.internal.dtm.DTMFilter}. * @return the node type for the whatToShow. Since whatToShow can specify * multiple types, it will return the first bit tested that is on, * so the caller of this function should take care that this is * the function they really want to call. If none of the known bits * are set, this function will return zero. */ public static int getNodeTypeTest(int whatToShow) { // %REVIEW% Is there a better way? if (0 != (whatToShow & DTMFilter.SHOW_ELEMENT)) return DTM.ELEMENT_NODE; if (0 != (whatToShow & DTMFilter.SHOW_ATTRIBUTE)) return DTM.ATTRIBUTE_NODE; if (0 != (whatToShow & DTMFilter.SHOW_TEXT)) return DTM.TEXT_NODE; if (0 != (whatToShow & DTMFilter.SHOW_DOCUMENT)) return DTM.DOCUMENT_NODE; if (0 != (whatToShow & DTMFilter.SHOW_DOCUMENT_FRAGMENT)) return DTM.DOCUMENT_FRAGMENT_NODE; if (0 != (whatToShow & DTMFilter.SHOW_NAMESPACE)) return DTM.NAMESPACE_NODE; if (0 != (whatToShow & DTMFilter.SHOW_COMMENT)) return DTM.COMMENT_NODE; if (0 != (whatToShow & DTMFilter.SHOW_PROCESSING_INSTRUCTION)) return DTM.PROCESSING_INSTRUCTION_NODE; if (0 != (whatToShow & DTMFilter.SHOW_DOCUMENT_TYPE)) return DTM.DOCUMENT_TYPE_NODE; if (0 != (whatToShow & DTMFilter.SHOW_ENTITY)) return DTM.ENTITY_NODE; if (0 != (whatToShow & DTMFilter.SHOW_ENTITY_REFERENCE)) return DTM.ENTITY_REFERENCE_NODE; if (0 != (whatToShow & DTMFilter.SHOW_NOTATION)) return DTM.NOTATION_NODE; if (0 != (whatToShow & DTMFilter.SHOW_CDATA_SECTION)) return DTM.CDATA_SECTION_NODE; return 0; }
Example 10
Source File: NodeTest.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
/** * Tell what node type to test, if not DTMFilter.SHOW_ALL. * * @param whatToShow Bit set defined mainly by * {@link com.sun.org.apache.xml.internal.dtm.DTMFilter}. * @return the node type for the whatToShow. Since whatToShow can specify * multiple types, it will return the first bit tested that is on, * so the caller of this function should take care that this is * the function they really want to call. If none of the known bits * are set, this function will return zero. */ public static int getNodeTypeTest(int whatToShow) { // %REVIEW% Is there a better way? if (0 != (whatToShow & DTMFilter.SHOW_ELEMENT)) return DTM.ELEMENT_NODE; if (0 != (whatToShow & DTMFilter.SHOW_ATTRIBUTE)) return DTM.ATTRIBUTE_NODE; if (0 != (whatToShow & DTMFilter.SHOW_TEXT)) return DTM.TEXT_NODE; if (0 != (whatToShow & DTMFilter.SHOW_DOCUMENT)) return DTM.DOCUMENT_NODE; if (0 != (whatToShow & DTMFilter.SHOW_DOCUMENT_FRAGMENT)) return DTM.DOCUMENT_FRAGMENT_NODE; if (0 != (whatToShow & DTMFilter.SHOW_NAMESPACE)) return DTM.NAMESPACE_NODE; if (0 != (whatToShow & DTMFilter.SHOW_COMMENT)) return DTM.COMMENT_NODE; if (0 != (whatToShow & DTMFilter.SHOW_PROCESSING_INSTRUCTION)) return DTM.PROCESSING_INSTRUCTION_NODE; if (0 != (whatToShow & DTMFilter.SHOW_DOCUMENT_TYPE)) return DTM.DOCUMENT_TYPE_NODE; if (0 != (whatToShow & DTMFilter.SHOW_ENTITY)) return DTM.ENTITY_NODE; if (0 != (whatToShow & DTMFilter.SHOW_ENTITY_REFERENCE)) return DTM.ENTITY_REFERENCE_NODE; if (0 != (whatToShow & DTMFilter.SHOW_NOTATION)) return DTM.NOTATION_NODE; if (0 != (whatToShow & DTMFilter.SHOW_CDATA_SECTION)) return DTM.CDATA_SECTION_NODE; return 0; }
Example 11
Source File: AbstractTranslet.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
/** * After constructing the translet object, this method must be called to * perform any version-specific post-initialization that's required. */ public final void postInitialization() { // If the version of the translet had just one namesArray, split // it into multiple fields. if (transletVersion < VER_SPLIT_NAMES_ARRAY) { int arraySize = namesArray.length; String[] newURIsArray = new String[arraySize]; String[] newNamesArray = new String[arraySize]; int[] newTypesArray = new int[arraySize]; for (int i = 0; i < arraySize; i++) { String name = namesArray[i]; int colonIndex = name.lastIndexOf(':'); int lNameStartIdx = colonIndex+1; if (colonIndex > -1) { newURIsArray[i] = name.substring(0, colonIndex); } // Distinguish attribute and element names. Attribute has // @ before local part of name. if (name.charAt(lNameStartIdx) == '@') { lNameStartIdx++; newTypesArray[i] = DTM.ATTRIBUTE_NODE; } else if (name.charAt(lNameStartIdx) == '?') { lNameStartIdx++; newTypesArray[i] = DTM.NAMESPACE_NODE; } else { newTypesArray[i] = DTM.ELEMENT_NODE; } newNamesArray[i] = (lNameStartIdx == 0) ? name : name.substring(lNameStartIdx); } namesArray = newNamesArray; urisArray = newURIsArray; typesArray = newTypesArray; } // Was translet compiled using a more recent version of the XSLTC // compiler than is known by the AbstractTranslet class? If, so // and we've made it this far (which is doubtful), we should give up. if (transletVersion > CURRENT_TRANSLET_VERSION) { BasisLibrary.runTimeError(BasisLibrary.UNKNOWN_TRANSLET_VERSION_ERR, this.getClass().getName()); } }
Example 12
Source File: SAXImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
private final void copy(final int node, SerializationHandler handler, boolean isChild) throws TransletException { int nodeID = makeNodeIdentity(node); int eType = _exptype2(nodeID); int type = _exptype2Type(eType); try { switch(type) { case DTM.ROOT_NODE: case DTM.DOCUMENT_NODE: for(int c = _firstch2(nodeID); c != DTM.NULL; c = _nextsib2(c)) { copy(makeNodeHandle(c), handler, true); } break; case DTM.PROCESSING_INSTRUCTION_NODE: copyPI(node, handler); break; case DTM.COMMENT_NODE: handler.comment(getStringValueX(node)); break; case DTM.TEXT_NODE: boolean oldEscapeSetting = false; boolean escapeBit = false; if (_dontEscape != null) { escapeBit = _dontEscape.getBit(getNodeIdent(node)); if (escapeBit) { oldEscapeSetting = handler.setEscaping(false); } } copyTextNode(nodeID, handler); if (escapeBit) { handler.setEscaping(oldEscapeSetting); } break; case DTM.ATTRIBUTE_NODE: copyAttribute(nodeID, eType, handler); break; case DTM.NAMESPACE_NODE: handler.namespaceAfterStartElement(getNodeNameX(node), getNodeValue(node)); break; default: if (type == DTM.ELEMENT_NODE) { // Start element definition final String name = copyElement(nodeID, eType, handler); //if(isChild) => not to copy any namespaces from parents // else copy all namespaces in scope copyNS(nodeID, handler,!isChild); copyAttributes(nodeID, handler); // Copy element children for (int c = _firstch2(nodeID); c != DTM.NULL; c = _nextsib2(c)) { copy(makeNodeHandle(c), handler, true); } // Close element definition handler.endElement(name); } // Shallow copy of attribute to output handler else { final String uri = getNamespaceName(node); if (uri.length() != 0) { final String prefix = getPrefix(node); handler.namespaceAfterStartElement(prefix, uri); } handler.addAttribute(getNodeName(node), getNodeValue(node)); } break; } } catch (Exception e) { throw new TransletException(e); } }
Example 13
Source File: SAX2DTM.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
/** * Construct the node map from the node. * * @param type raw type ID, one of DTM.XXX_NODE. * @param expandedTypeID The expended type ID. * @param parentIndex The current parent index. * @param previousSibling The previous sibling index. * @param dataOrPrefix index into m_data table, or string handle. * @param canHaveFirstChild true if the node can have a first child, false * if it is atomic. * * @return The index identity of the node that was added. */ protected int addNode(int type, int expandedTypeID, int parentIndex, int previousSibling, int dataOrPrefix, boolean canHaveFirstChild) { // Common to all nodes: int nodeIndex = m_size++; // Have we overflowed a DTM Identity's addressing range? if(m_dtmIdent.size() == (nodeIndex>>>DTMManager.IDENT_DTM_NODE_BITS)) { addNewDTMID(nodeIndex); } m_firstch.addElement(canHaveFirstChild ? NOTPROCESSED : DTM.NULL); m_nextsib.addElement(NOTPROCESSED); m_parent.addElement(parentIndex); m_exptype.addElement(expandedTypeID); m_dataOrQName.addElement(dataOrPrefix); if (m_prevsib != null) { m_prevsib.addElement(previousSibling); } if (DTM.NULL != previousSibling) { m_nextsib.setElementAt(nodeIndex,previousSibling); } if (m_locator != null && m_useSourceLocationProperty) { setSourceLocation(); } // Note that nextSibling is not processed until charactersFlush() // is called, to handle successive characters() events. // Special handling by type: Declare namespaces, attach first child switch(type) { case DTM.NAMESPACE_NODE: declareNamespaceInContext(parentIndex,nodeIndex); break; case DTM.ATTRIBUTE_NODE: break; default: if (DTM.NULL == previousSibling && DTM.NULL != parentIndex) { m_firstch.setElementAt(nodeIndex,parentIndex); } break; } return nodeIndex; }
Example 14
Source File: DOM2DTM.java From Bytecoder with Apache License 2.0 | 4 votes |
/** * 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) { // %OPT% This is probably slower than it needs to be. if (null == namespaceURI) namespaceURI = ""; int type = getNodeType(nodeHandle); if (DTM.ELEMENT_NODE == type) { // Assume that attributes immediately follow the element. int identity = makeNodeIdentity(nodeHandle); while (DTM.NULL != (identity = getNextNodeIdentity(identity))) { // Assume this can not be null. type = _type(identity); // %REVIEW% // Should namespace nodes be retrievable DOM-style as attrs? // If not we need a separate function... which may be desirable // architecturally, but which is ugly from a code point of view. // (If we REALLY insist on it, this code should become a subroutine // of both -- retrieve the node, then test if the type matches // what you're looking for.) if (type == DTM.ATTRIBUTE_NODE || type==DTM.NAMESPACE_NODE) { Node node = lookupNode(identity); String nodeuri = node.getNamespaceURI(); if (null == nodeuri) nodeuri = ""; String nodelocalname = node.getLocalName(); if (nodeuri.equals(namespaceURI) && name.equals(nodelocalname)) return makeNodeHandle(identity); } else // if (DTM.NAMESPACE_NODE != type) { break; } } } return DTM.NULL; }
Example 15
Source File: NodeTest.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
/** * Tell what node type to test, if not DTMFilter.SHOW_ALL. * * @param whatToShow Bit set defined mainly by * {@link com.sun.org.apache.xml.internal.dtm.DTMFilter}. * @return the node type for the whatToShow. Since whatToShow can specify * multiple types, it will return the first bit tested that is on, * so the caller of this function should take care that this is * the function they really want to call. If none of the known bits * are set, this function will return zero. */ public static int getNodeTypeTest(int whatToShow) { // %REVIEW% Is there a better way? if (0 != (whatToShow & DTMFilter.SHOW_ELEMENT)) return DTM.ELEMENT_NODE; if (0 != (whatToShow & DTMFilter.SHOW_ATTRIBUTE)) return DTM.ATTRIBUTE_NODE; if (0 != (whatToShow & DTMFilter.SHOW_TEXT)) return DTM.TEXT_NODE; if (0 != (whatToShow & DTMFilter.SHOW_DOCUMENT)) return DTM.DOCUMENT_NODE; if (0 != (whatToShow & DTMFilter.SHOW_DOCUMENT_FRAGMENT)) return DTM.DOCUMENT_FRAGMENT_NODE; if (0 != (whatToShow & DTMFilter.SHOW_NAMESPACE)) return DTM.NAMESPACE_NODE; if (0 != (whatToShow & DTMFilter.SHOW_COMMENT)) return DTM.COMMENT_NODE; if (0 != (whatToShow & DTMFilter.SHOW_PROCESSING_INSTRUCTION)) return DTM.PROCESSING_INSTRUCTION_NODE; if (0 != (whatToShow & DTMFilter.SHOW_DOCUMENT_TYPE)) return DTM.DOCUMENT_TYPE_NODE; if (0 != (whatToShow & DTMFilter.SHOW_ENTITY)) return DTM.ENTITY_NODE; if (0 != (whatToShow & DTMFilter.SHOW_ENTITY_REFERENCE)) return DTM.ENTITY_REFERENCE_NODE; if (0 != (whatToShow & DTMFilter.SHOW_NOTATION)) return DTM.NOTATION_NODE; if (0 != (whatToShow & DTMFilter.SHOW_CDATA_SECTION)) return DTM.CDATA_SECTION_NODE; return 0; }
Example 16
Source File: SAX2DTM2.java From Bytecoder with Apache License 2.0 | 4 votes |
/** * Construct the node map from the node. * * @param type raw type ID, one of DTM.XXX_NODE. * @param expandedTypeID The expended type ID. * @param parentIndex The current parent index. * @param previousSibling The previous sibling index. * @param dataOrPrefix index into m_data table, or string handle. * @param canHaveFirstChild true if the node can have a first child, false * if it is atomic. * * @return The index identity of the node that was added. */ protected final int addNode(int type, int expandedTypeID, int parentIndex, int previousSibling, int dataOrPrefix, boolean canHaveFirstChild) { // Common to all nodes: int nodeIndex = m_size++; // Have we overflowed a DTM Identity's addressing range? //if(m_dtmIdent.size() == (nodeIndex>>>DTMManager.IDENT_DTM_NODE_BITS)) if (nodeIndex == m_maxNodeIndex) { addNewDTMID(nodeIndex); m_maxNodeIndex += (1 << DTMManager.IDENT_DTM_NODE_BITS); } m_firstch.addElement(DTM.NULL); m_nextsib.addElement(DTM.NULL); m_parent.addElement(parentIndex); m_exptype.addElement(expandedTypeID); m_dataOrQName.addElement(dataOrPrefix); if (m_prevsib != null) { m_prevsib.addElement(previousSibling); } if (m_locator != null && m_useSourceLocationProperty) { setSourceLocation(); } // Note that nextSibling is not processed until charactersFlush() // is called, to handle successive characters() events. // Special handling by type: Declare namespaces, attach first child switch(type) { case DTM.NAMESPACE_NODE: declareNamespaceInContext(parentIndex,nodeIndex); break; case DTM.ATTRIBUTE_NODE: break; default: if (DTM.NULL != previousSibling) { m_nextsib.setElementAt(nodeIndex,previousSibling); } else if (DTM.NULL != parentIndex) { m_firstch.setElementAt(nodeIndex,parentIndex); } break; } return nodeIndex; }
Example 17
Source File: DOM2DTM.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
/** * 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) { // %OPT% This is probably slower than it needs to be. if (null == namespaceURI) namespaceURI = ""; int type = getNodeType(nodeHandle); if (DTM.ELEMENT_NODE == type) { // Assume that attributes immediately follow the element. int identity = makeNodeIdentity(nodeHandle); while (DTM.NULL != (identity = getNextNodeIdentity(identity))) { // Assume this can not be null. type = _type(identity); // %REVIEW% // Should namespace nodes be retrievable DOM-style as attrs? // If not we need a separate function... which may be desirable // architecturally, but which is ugly from a code point of view. // (If we REALLY insist on it, this code should become a subroutine // of both -- retrieve the node, then test if the type matches // what you're looking for.) if (type == DTM.ATTRIBUTE_NODE || type==DTM.NAMESPACE_NODE) { Node node = lookupNode(identity); String nodeuri = node.getNamespaceURI(); if (null == nodeuri) nodeuri = ""; String nodelocalname = node.getLocalName(); if (nodeuri.equals(namespaceURI) && name.equals(nodelocalname)) return makeNodeHandle(identity); } else // if (DTM.NAMESPACE_NODE != type) { break; } } } return DTM.NULL; }
Example 18
Source File: AbstractTranslet.java From jdk1.8-source-analysis with Apache License 2.0 | 4 votes |
/** * After constructing the translet object, this method must be called to * perform any version-specific post-initialization that's required. */ public final void postInitialization() { // If the version of the translet had just one namesArray, split // it into multiple fields. if (transletVersion < VER_SPLIT_NAMES_ARRAY) { int arraySize = namesArray.length; String[] newURIsArray = new String[arraySize]; String[] newNamesArray = new String[arraySize]; int[] newTypesArray = new int[arraySize]; for (int i = 0; i < arraySize; i++) { String name = namesArray[i]; int colonIndex = name.lastIndexOf(':'); int lNameStartIdx = colonIndex+1; if (colonIndex > -1) { newURIsArray[i] = name.substring(0, colonIndex); } // Distinguish attribute and element names. Attribute has // @ before local part of name. if (name.charAt(lNameStartIdx) == '@') { lNameStartIdx++; newTypesArray[i] = DTM.ATTRIBUTE_NODE; } else if (name.charAt(lNameStartIdx) == '?') { lNameStartIdx++; newTypesArray[i] = DTM.NAMESPACE_NODE; } else { newTypesArray[i] = DTM.ELEMENT_NODE; } newNamesArray[i] = (lNameStartIdx == 0) ? name : name.substring(lNameStartIdx); } namesArray = newNamesArray; urisArray = newURIsArray; typesArray = newTypesArray; } // Was translet compiled using a more recent version of the XSLTC // compiler than is known by the AbstractTranslet class? If, so // and we've made it this far (which is doubtful), we should give up. if (transletVersion > CURRENT_TRANSLET_VERSION) { BasisLibrary.runTimeError(BasisLibrary.UNKNOWN_TRANSLET_VERSION_ERR, this.getClass().getName()); } }
Example 19
Source File: NodeTest.java From hottub with GNU General Public License v2.0 | 4 votes |
/** * Tell what node type to test, if not DTMFilter.SHOW_ALL. * * @param whatToShow Bit set defined mainly by * {@link com.sun.org.apache.xml.internal.dtm.DTMFilter}. * @return the node type for the whatToShow. Since whatToShow can specify * multiple types, it will return the first bit tested that is on, * so the caller of this function should take care that this is * the function they really want to call. If none of the known bits * are set, this function will return zero. */ public static int getNodeTypeTest(int whatToShow) { // %REVIEW% Is there a better way? if (0 != (whatToShow & DTMFilter.SHOW_ELEMENT)) return DTM.ELEMENT_NODE; if (0 != (whatToShow & DTMFilter.SHOW_ATTRIBUTE)) return DTM.ATTRIBUTE_NODE; if (0 != (whatToShow & DTMFilter.SHOW_TEXT)) return DTM.TEXT_NODE; if (0 != (whatToShow & DTMFilter.SHOW_DOCUMENT)) return DTM.DOCUMENT_NODE; if (0 != (whatToShow & DTMFilter.SHOW_DOCUMENT_FRAGMENT)) return DTM.DOCUMENT_FRAGMENT_NODE; if (0 != (whatToShow & DTMFilter.SHOW_NAMESPACE)) return DTM.NAMESPACE_NODE; if (0 != (whatToShow & DTMFilter.SHOW_COMMENT)) return DTM.COMMENT_NODE; if (0 != (whatToShow & DTMFilter.SHOW_PROCESSING_INSTRUCTION)) return DTM.PROCESSING_INSTRUCTION_NODE; if (0 != (whatToShow & DTMFilter.SHOW_DOCUMENT_TYPE)) return DTM.DOCUMENT_TYPE_NODE; if (0 != (whatToShow & DTMFilter.SHOW_ENTITY)) return DTM.ENTITY_NODE; if (0 != (whatToShow & DTMFilter.SHOW_ENTITY_REFERENCE)) return DTM.ENTITY_REFERENCE_NODE; if (0 != (whatToShow & DTMFilter.SHOW_NOTATION)) return DTM.NOTATION_NODE; if (0 != (whatToShow & DTMFilter.SHOW_CDATA_SECTION)) return DTM.CDATA_SECTION_NODE; return 0; }
Example 20
Source File: SAXImpl.java From jdk1.8-source-analysis with Apache License 2.0 | 4 votes |
private final void copy(final int node, SerializationHandler handler, boolean isChild) throws TransletException { int nodeID = makeNodeIdentity(node); int eType = _exptype2(nodeID); int type = _exptype2Type(eType); try { switch(type) { case DTM.ROOT_NODE: case DTM.DOCUMENT_NODE: for(int c = _firstch2(nodeID); c != DTM.NULL; c = _nextsib2(c)) { copy(makeNodeHandle(c), handler, true); } break; case DTM.PROCESSING_INSTRUCTION_NODE: copyPI(node, handler); break; case DTM.COMMENT_NODE: handler.comment(getStringValueX(node)); break; case DTM.TEXT_NODE: boolean oldEscapeSetting = false; boolean escapeBit = false; if (_dontEscape != null) { escapeBit = _dontEscape.getBit(getNodeIdent(node)); if (escapeBit) { oldEscapeSetting = handler.setEscaping(false); } } copyTextNode(nodeID, handler); if (escapeBit) { handler.setEscaping(oldEscapeSetting); } break; case DTM.ATTRIBUTE_NODE: copyAttribute(nodeID, eType, handler); break; case DTM.NAMESPACE_NODE: handler.namespaceAfterStartElement(getNodeNameX(node), getNodeValue(node)); break; default: if (type == DTM.ELEMENT_NODE) { // Start element definition final String name = copyElement(nodeID, eType, handler); //if(isChild) => not to copy any namespaces from parents // else copy all namespaces in scope copyNS(nodeID, handler,!isChild); copyAttributes(nodeID, handler); // Copy element children for (int c = _firstch2(nodeID); c != DTM.NULL; c = _nextsib2(c)) { copy(makeNodeHandle(c), handler, true); } // Close element definition handler.endElement(name); } // Shallow copy of attribute to output handler else { final String uri = getNamespaceName(node); if (uri.length() != 0) { final String prefix = getPrefix(node); handler.namespaceAfterStartElement(prefix, uri); } handler.addAttribute(getNodeName(node), getNodeValue(node)); } break; } } catch (Exception e) { throw new TransletException(e); } }