Java Code Examples for org.w3c.dom.Node#ENTITY_NODE
The following examples show how to use
org.w3c.dom.Node#ENTITY_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: RangeImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Returns true IFF the given node can serve as a container * for a range's boundary points. */ private boolean isLegalContainer( Node node ) { if ( node==null ) return false; while( node!=null ) { switch( node.getNodeType() ) { case Node.ENTITY_NODE: case Node.NOTATION_NODE: case Node.DOCUMENT_TYPE_NODE: return false; } node = node.getParentNode(); } return true; }
Example 2
Source File: DOM2SAX.java From JDKSourceCode1.8 with MIT License | 5 votes |
private String getNodeTypeFromCode(short code) { String retval = null; switch (code) { case Node.ATTRIBUTE_NODE : retval = "ATTRIBUTE_NODE"; break; case Node.CDATA_SECTION_NODE : retval = "CDATA_SECTION_NODE"; break; case Node.COMMENT_NODE : retval = "COMMENT_NODE"; break; case Node.DOCUMENT_FRAGMENT_NODE : retval = "DOCUMENT_FRAGMENT_NODE"; break; case Node.DOCUMENT_NODE : retval = "DOCUMENT_NODE"; break; case Node.DOCUMENT_TYPE_NODE : retval = "DOCUMENT_TYPE_NODE"; break; case Node.ELEMENT_NODE : retval = "ELEMENT_NODE"; break; case Node.ENTITY_NODE : retval = "ENTITY_NODE"; break; case Node.ENTITY_REFERENCE_NODE : retval = "ENTITY_REFERENCE_NODE"; break; case Node.NOTATION_NODE : retval = "NOTATION_NODE"; break; case Node.PROCESSING_INSTRUCTION_NODE : retval = "PROCESSING_INSTRUCTION_NODE"; break; case Node.TEXT_NODE: retval = "TEXT_NODE"; break; } return retval; }
Example 3
Source File: DOMPrinter.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public void print(Node node) throws XMLStreamException { switch (node.getNodeType()) { case Node.DOCUMENT_NODE: visitDocument((Document) node); break; case Node.DOCUMENT_FRAGMENT_NODE: visitDocumentFragment((DocumentFragment) node); break; case Node.ELEMENT_NODE: visitElement((Element) node); break; case Node.TEXT_NODE: visitText((Text) node); break; case Node.CDATA_SECTION_NODE: visitCDATASection((CDATASection) node); break; case Node.PROCESSING_INSTRUCTION_NODE: visitProcessingInstruction((ProcessingInstruction) node); break; case Node.ENTITY_REFERENCE_NODE: visitReference((EntityReference) node); break; case Node.COMMENT_NODE: visitComment((Comment) node); break; case Node.DOCUMENT_TYPE_NODE: break; case Node.ATTRIBUTE_NODE: case Node.ENTITY_NODE: default: throw new XMLStreamException("Unexpected DOM Node Type " + node.getNodeType() ); } }
Example 4
Source File: AbstractNodeTester.java From xmlunit with Apache License 2.0 | 5 votes |
/** * Validate a single Node by delegating to node type specific methods. * @see #testAttribute(Attr) * @see #testCDATASection(CDATASection) * @see #testComment(Comment) * @see #testDocumentType(DocumentType) * @see #testElement(Element) * @see #testEntity(Entity) * @see #testEntityReference(EntityReference) * @see #testNotation(Notation) * @see #testProcessingInstruction(ProcessingInstruction) * @see #testText(Text) */ public void testNode(Node aNode, NodeTest forTest) throws NodeTestException { switch (aNode.getNodeType()) { case Node.ATTRIBUTE_NODE: // should not happen as attributes are not exposed by DOM traversal testAttribute((Attr)aNode); break; case Node.CDATA_SECTION_NODE: testCDATASection((CDATASection)aNode); break; case Node.COMMENT_NODE: testComment((Comment)aNode); break; case Node.DOCUMENT_TYPE_NODE: testDocumentType((DocumentType)aNode); break; case Node.ELEMENT_NODE: testElement((Element)aNode); break; case Node.ENTITY_NODE: testEntity((Entity)aNode); break; case Node.ENTITY_REFERENCE_NODE: testEntityReference((EntityReference)aNode); break; case Node.NOTATION_NODE: testNotation((Notation)aNode); break; case Node.PROCESSING_INSTRUCTION_NODE: testProcessingInstruction( (ProcessingInstruction) aNode); break; case Node.TEXT_NODE: testText((Text)aNode); break; default: throw new NodeTestException("No delegate method for Node type", aNode); } }
Example 5
Source File: DOM2TO.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private String getNodeTypeFromCode(short code) { String retval = null; switch (code) { case Node.ATTRIBUTE_NODE : retval = "ATTRIBUTE_NODE"; break; case Node.CDATA_SECTION_NODE : retval = "CDATA_SECTION_NODE"; break; case Node.COMMENT_NODE : retval = "COMMENT_NODE"; break; case Node.DOCUMENT_FRAGMENT_NODE : retval = "DOCUMENT_FRAGMENT_NODE"; break; case Node.DOCUMENT_NODE : retval = "DOCUMENT_NODE"; break; case Node.DOCUMENT_TYPE_NODE : retval = "DOCUMENT_TYPE_NODE"; break; case Node.ELEMENT_NODE : retval = "ELEMENT_NODE"; break; case Node.ENTITY_NODE : retval = "ENTITY_NODE"; break; case Node.ENTITY_REFERENCE_NODE : retval = "ENTITY_REFERENCE_NODE"; break; case Node.NOTATION_NODE : retval = "NOTATION_NODE"; break; case Node.PROCESSING_INSTRUCTION_NODE : retval = "PROCESSING_INSTRUCTION_NODE"; break; case Node.TEXT_NODE: retval = "TEXT_NODE"; break; } return retval; }
Example 6
Source File: DomTreeWalker.java From htmlunit with Apache License 2.0 | 5 votes |
/** * Given a {@link Node}, return the appropriate constant for whatToShow. * * @param node the node * @return the whatToShow constant for the type of specified node */ static int getFlagForNode(final Node node) { switch (node.getNodeType()) { case Node.ELEMENT_NODE: return NodeFilter.SHOW_ELEMENT; case Node.ATTRIBUTE_NODE: return NodeFilter.SHOW_ATTRIBUTE; case Node.TEXT_NODE: return NodeFilter.SHOW_TEXT; case Node.CDATA_SECTION_NODE: return NodeFilter.SHOW_CDATA_SECTION; case Node.ENTITY_REFERENCE_NODE: return NodeFilter.SHOW_ENTITY_REFERENCE; case Node.ENTITY_NODE: return NodeFilter.SHOW_ENTITY; case Node.PROCESSING_INSTRUCTION_NODE: return NodeFilter.SHOW_PROCESSING_INSTRUCTION; case Node.COMMENT_NODE: return NodeFilter.SHOW_COMMENT; case Node.DOCUMENT_NODE: return NodeFilter.SHOW_DOCUMENT; case Node.DOCUMENT_TYPE_NODE: return NodeFilter.SHOW_DOCUMENT_TYPE; case Node.DOCUMENT_FRAGMENT_NODE: return NodeFilter.SHOW_DOCUMENT_FRAGMENT; case Node.NOTATION_NODE: return NodeFilter.SHOW_NOTATION; default: return 0; } }
Example 7
Source File: NodeImpl.java From hottub with GNU General Public License v2.0 | 4 votes |
/** * * DOM Level 3 - Experimental: * Look up the prefix associated to the given namespace URI, starting from this node. * * @param namespaceURI * @return the prefix for the namespace */ public String lookupPrefix(String namespaceURI){ // REVISIT: When Namespaces 1.1 comes out this may not be true // Prefix can't be bound to null namespace if (namespaceURI == null) { return null; } short type = this.getNodeType(); switch (type) { case Node.ELEMENT_NODE: { String namespace = this.getNamespaceURI(); // to flip out children return lookupNamespacePrefix(namespaceURI, (ElementImpl)this); } case Node.DOCUMENT_NODE:{ return((NodeImpl)((Document)this).getDocumentElement()).lookupPrefix(namespaceURI); } case Node.ENTITY_NODE : case Node.NOTATION_NODE: case Node.DOCUMENT_FRAGMENT_NODE: case Node.DOCUMENT_TYPE_NODE: // type is unknown return null; case Node.ATTRIBUTE_NODE:{ if (this.ownerNode.getNodeType() == Node.ELEMENT_NODE) { return ownerNode.lookupPrefix(namespaceURI); } return null; } default:{ NodeImpl ancestor = (NodeImpl)getElementAncestor(this); if (ancestor != null) { return ancestor.lookupPrefix(namespaceURI); } return null; } } }
Example 8
Source File: DTMNodeProxy.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
/** * * DOM Level 3 * Look up the prefix associated to the given namespace URI, starting from this node. * * @param namespaceURI * @return the prefix for the namespace */ @Override public String lookupPrefix(String namespaceURI){ // REVISIT: When Namespaces 1.1 comes out this may not be true // Prefix can't be bound to null namespace if (namespaceURI == null) { return null; } short type = this.getNodeType(); switch (type) { /* case Node.ELEMENT_NODE: { String namespace = this.getNamespaceURI(); // to flip out children return lookupNamespacePrefix(namespaceURI, (ElementImpl)this); } case Node.DOCUMENT_NODE:{ return((NodeImpl)((Document)this).getDocumentElement()).lookupPrefix(namespaceURI); } */ case Node.ENTITY_NODE : case Node.NOTATION_NODE: case Node.DOCUMENT_FRAGMENT_NODE: case Node.DOCUMENT_TYPE_NODE: // type is unknown return null; case Node.ATTRIBUTE_NODE:{ if (this.getOwnerElement().getNodeType() == Node.ELEMENT_NODE) { return getOwnerElement().lookupPrefix(namespaceURI); } return null; } default:{ /* NodeImpl ancestor = (NodeImpl)getElementAncestor(this); if (ancestor != null) { return ancestor.lookupPrefix(namespaceURI); } */ return null; } } }
Example 9
Source File: DTMNodeProxy.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
/** * DOM Level 3 * Look up the namespace URI associated to the given prefix, starting from this node. * Use lookupNamespaceURI(null) to lookup the default namespace * * @param namespaceURI * @return th URI for the namespace * @since DOM Level 3 */ @Override public String lookupNamespaceURI(String specifiedPrefix) { short type = this.getNodeType(); switch (type) { case Node.ELEMENT_NODE : { String namespace = this.getNamespaceURI(); String prefix = this.getPrefix(); if (namespace !=null) { // REVISIT: is it possible that prefix is empty string? if (specifiedPrefix== null && prefix==specifiedPrefix) { // looking for default namespace return namespace; } else if (prefix != null && prefix.equals(specifiedPrefix)) { // non default namespace return namespace; } } if (this.hasAttributes()) { NamedNodeMap map = this.getAttributes(); int length = map.getLength(); for (int i=0;i<length;i++) { Node attr = map.item(i); String attrPrefix = attr.getPrefix(); String value = attr.getNodeValue(); namespace = attr.getNamespaceURI(); if (namespace !=null && namespace.equals("http://www.w3.org/2000/xmlns/")) { // at this point we are dealing with DOM Level 2 nodes only if (specifiedPrefix == null && attr.getNodeName().equals("xmlns")) { // default namespace return value; } else if (attrPrefix !=null && attrPrefix.equals("xmlns") && attr.getLocalName().equals(specifiedPrefix)) { // non default namespace return value; } } } } /* NodeImpl ancestor = (NodeImpl)getElementAncestor(this); if (ancestor != null) { return ancestor.lookupNamespaceURI(specifiedPrefix); } */ return null; } /* case Node.DOCUMENT_NODE : { return((NodeImpl)((Document)this).getDocumentElement()).lookupNamespaceURI(specifiedPrefix) ; } */ case Node.ENTITY_NODE : case Node.NOTATION_NODE: case Node.DOCUMENT_FRAGMENT_NODE: case Node.DOCUMENT_TYPE_NODE: // type is unknown return null; case Node.ATTRIBUTE_NODE:{ if (this.getOwnerElement().getNodeType() == Node.ELEMENT_NODE) { return getOwnerElement().lookupNamespaceURI(specifiedPrefix); } return null; } default:{ /* NodeImpl ancestor = (NodeImpl)getElementAncestor(this); if (ancestor != null) { return ancestor.lookupNamespaceURI(specifiedPrefix); } */ return null; } } }
Example 10
Source File: DOM2DTMdefaultNamespaceDeclarationNode.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
/** * DOM Level 3 - Experimental: * Look up the namespace URI associated to the given prefix, starting from this node. * Use lookupNamespaceURI(null) to lookup the default namespace * * @param namespaceURI * @return th URI for the namespace * @since DOM Level 3 */ public String lookupNamespaceURI(String specifiedPrefix) { short type = this.getNodeType(); switch (type) { case Node.ELEMENT_NODE : { String namespace = this.getNamespaceURI(); String prefix = this.getPrefix(); if (namespace !=null) { // REVISIT: is it possible that prefix is empty string? if (specifiedPrefix== null && prefix==specifiedPrefix) { // looking for default namespace return namespace; } else if (prefix != null && prefix.equals(specifiedPrefix)) { // non default namespace return namespace; } } if (this.hasAttributes()) { NamedNodeMap map = this.getAttributes(); int length = map.getLength(); for (int i=0;i<length;i++) { Node attr = map.item(i); String attrPrefix = attr.getPrefix(); String value = attr.getNodeValue(); namespace = attr.getNamespaceURI(); if (namespace !=null && namespace.equals("http://www.w3.org/2000/xmlns/")) { // at this point we are dealing with DOM Level 2 nodes only if (specifiedPrefix == null && attr.getNodeName().equals("xmlns")) { // default namespace return value; } else if (attrPrefix !=null && attrPrefix.equals("xmlns") && attr.getLocalName().equals(specifiedPrefix)) { // non default namespace return value; } } } } /* NodeImpl ancestor = (NodeImpl)getElementAncestor(this); if (ancestor != null) { return ancestor.lookupNamespaceURI(specifiedPrefix); } */ return null; } /* case Node.DOCUMENT_NODE : { return((NodeImpl)((Document)this).getDocumentElement()).lookupNamespaceURI(specifiedPrefix) ; } */ case Node.ENTITY_NODE : case Node.NOTATION_NODE: case Node.DOCUMENT_FRAGMENT_NODE: case Node.DOCUMENT_TYPE_NODE: // type is unknown return null; case Node.ATTRIBUTE_NODE:{ if (this.getOwnerElement().getNodeType() == Node.ELEMENT_NODE) { return getOwnerElement().lookupNamespaceURI(specifiedPrefix); } return null; } default:{ /* NodeImpl ancestor = (NodeImpl)getElementAncestor(this); if (ancestor != null) { return ancestor.lookupNamespaceURI(specifiedPrefix); } */ return null; } } }
Example 11
Source File: RangeImpl.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
public void insertNode(Node newNode) throws DOMException, RangeException { if ( newNode == null ) return; //throw exception? int type = newNode.getNodeType(); if (fDocument.errorChecking) { if (fDetach) { throw new DOMException( DOMException.INVALID_STATE_ERR, DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INVALID_STATE_ERR", null)); } if ( fDocument != newNode.getOwnerDocument() ) { throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "WRONG_DOCUMENT_ERR", null)); } if (type == Node.ATTRIBUTE_NODE || type == Node.ENTITY_NODE || type == Node.NOTATION_NODE || type == Node.DOCUMENT_NODE) { throw new RangeExceptionImpl( RangeException.INVALID_NODE_TYPE_ERR, DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INVALID_NODE_TYPE_ERR", null)); } } Node cloneCurrent; Node current; int currentChildren = 0; fInsertedFromRange = true; //boolean MULTIPLE_MODE = false; if (fStartContainer.getNodeType() == Node.TEXT_NODE) { Node parent = fStartContainer.getParentNode(); currentChildren = parent.getChildNodes().getLength(); //holds number of kids before insertion // split text node: results is 3 nodes.. cloneCurrent = fStartContainer.cloneNode(false); ((TextImpl)cloneCurrent).setNodeValueInternal( (cloneCurrent.getNodeValue()).substring(fStartOffset)); ((TextImpl)fStartContainer).setNodeValueInternal( (fStartContainer.getNodeValue()).substring(0,fStartOffset)); Node next = fStartContainer.getNextSibling(); if (next != null) { if (parent != null) { parent.insertBefore(newNode, next); parent.insertBefore(cloneCurrent, next); } } else { if (parent != null) { parent.appendChild(newNode); parent.appendChild(cloneCurrent); } } //update ranges after the insertion if ( fEndContainer == fStartContainer) { fEndContainer = cloneCurrent; //endContainer is the new Node created fEndOffset -= fStartOffset; } else if ( fEndContainer == parent ) { //endContainer was not a text Node. //endOffset + = number_of_children_added fEndOffset += (parent.getChildNodes().getLength() - currentChildren); } // signal other Ranges to update their start/end containers/offsets signalSplitData(fStartContainer, cloneCurrent, fStartOffset); } else { // ! TEXT_NODE if ( fEndContainer == fStartContainer ) //need to remember number of kids currentChildren= fEndContainer.getChildNodes().getLength(); current = fStartContainer.getFirstChild(); int i = 0; for(i = 0; i < fStartOffset && current != null; i++) { current=current.getNextSibling(); } if (current != null) { fStartContainer.insertBefore(newNode, current); } else { fStartContainer.appendChild(newNode); } //update fEndOffset. ex:<body><p/></body>. Range(start;end): body,0; body,1 // insert <h1>: <body></h1><p/></body>. Range(start;end): body,0; body,2 if ( fEndContainer == fStartContainer && fEndOffset != 0 ) { //update fEndOffset if not 0 fEndOffset += (fEndContainer.getChildNodes().getLength() - currentChildren); } } fInsertedFromRange = false; }
Example 12
Source File: DOM2DTMdefaultNamespaceDeclarationNode.java From jdk1.8-source-analysis with Apache License 2.0 | 4 votes |
/** * DOM Level 3 - Experimental: * Look up the namespace URI associated to the given prefix, starting from this node. * Use lookupNamespaceURI(null) to lookup the default namespace * * @param namespaceURI * @return th URI for the namespace * @since DOM Level 3 */ public String lookupNamespaceURI(String specifiedPrefix) { short type = this.getNodeType(); switch (type) { case Node.ELEMENT_NODE : { String namespace = this.getNamespaceURI(); String prefix = this.getPrefix(); if (namespace !=null) { // REVISIT: is it possible that prefix is empty string? if (specifiedPrefix== null && prefix==specifiedPrefix) { // looking for default namespace return namespace; } else if (prefix != null && prefix.equals(specifiedPrefix)) { // non default namespace return namespace; } } if (this.hasAttributes()) { NamedNodeMap map = this.getAttributes(); int length = map.getLength(); for (int i=0;i<length;i++) { Node attr = map.item(i); String attrPrefix = attr.getPrefix(); String value = attr.getNodeValue(); namespace = attr.getNamespaceURI(); if (namespace !=null && namespace.equals("http://www.w3.org/2000/xmlns/")) { // at this point we are dealing with DOM Level 2 nodes only if (specifiedPrefix == null && attr.getNodeName().equals("xmlns")) { // default namespace return value; } else if (attrPrefix !=null && attrPrefix.equals("xmlns") && attr.getLocalName().equals(specifiedPrefix)) { // non default namespace return value; } } } } /* NodeImpl ancestor = (NodeImpl)getElementAncestor(this); if (ancestor != null) { return ancestor.lookupNamespaceURI(specifiedPrefix); } */ return null; } /* case Node.DOCUMENT_NODE : { return((NodeImpl)((Document)this).getDocumentElement()).lookupNamespaceURI(specifiedPrefix) ; } */ case Node.ENTITY_NODE : case Node.NOTATION_NODE: case Node.DOCUMENT_FRAGMENT_NODE: case Node.DOCUMENT_TYPE_NODE: // type is unknown return null; case Node.ATTRIBUTE_NODE:{ if (this.getOwnerElement().getNodeType() == Node.ELEMENT_NODE) { return getOwnerElement().lookupNamespaceURI(specifiedPrefix); } return null; } default:{ /* NodeImpl ancestor = (NodeImpl)getElementAncestor(this); if (ancestor != null) { return ancestor.lookupNamespaceURI(specifiedPrefix); } */ return null; } } }
Example 13
Source File: UnImplNode.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
/** * DOM Level 3 - Experimental: * Look up the namespace URI associated to the given prefix, starting from this node. * Use lookupNamespaceURI(null) to lookup the default namespace * * @param namespaceURI * @return th URI for the namespace * @since DOM Level 3 */ public String lookupNamespaceURI(String specifiedPrefix) { short type = this.getNodeType(); switch (type) { case Node.ELEMENT_NODE : { String namespace = this.getNamespaceURI(); String prefix = this.getPrefix(); if (namespace !=null) { // REVISIT: is it possible that prefix is empty string? if (specifiedPrefix== null && prefix==specifiedPrefix) { // looking for default namespace return namespace; } else if (prefix != null && prefix.equals(specifiedPrefix)) { // non default namespace return namespace; } } if (this.hasAttributes()) { NamedNodeMap map = this.getAttributes(); int length = map.getLength(); for (int i=0;i<length;i++) { Node attr = map.item(i); String attrPrefix = attr.getPrefix(); String value = attr.getNodeValue(); namespace = attr.getNamespaceURI(); if (namespace !=null && namespace.equals("http://www.w3.org/2000/xmlns/")) { // at this point we are dealing with DOM Level 2 nodes only if (specifiedPrefix == null && attr.getNodeName().equals("xmlns")) { // default namespace return value; } else if (attrPrefix !=null && attrPrefix.equals("xmlns") && attr.getLocalName().equals(specifiedPrefix)) { // non default namespace return value; } } } } /* NodeImpl ancestor = (NodeImpl)getElementAncestor(this); if (ancestor != null) { return ancestor.lookupNamespaceURI(specifiedPrefix); } */ return null; } /* case Node.DOCUMENT_NODE : { return((NodeImpl)((Document)this).getDocumentElement()).lookupNamespaceURI(specifiedPrefix) ; } */ case Node.ENTITY_NODE : case Node.NOTATION_NODE: case Node.DOCUMENT_FRAGMENT_NODE: case Node.DOCUMENT_TYPE_NODE: // type is unknown return null; case Node.ATTRIBUTE_NODE:{ if (this.getOwnerElement().getNodeType() == Node.ELEMENT_NODE) { return getOwnerElement().lookupNamespaceURI(specifiedPrefix); } return null; } default:{ /* NodeImpl ancestor = (NodeImpl)getElementAncestor(this); if (ancestor != null) { return ancestor.lookupNamespaceURI(specifiedPrefix); } */ return null; } } }
Example 14
Source File: NodeImpl.java From JDKSourceCode1.8 with MIT License | 4 votes |
/** * * DOM Level 3 - Experimental: * Look up the prefix associated to the given namespace URI, starting from this node. * * @param namespaceURI * @return the prefix for the namespace */ public String lookupPrefix(String namespaceURI){ // REVISIT: When Namespaces 1.1 comes out this may not be true // Prefix can't be bound to null namespace if (namespaceURI == null) { return null; } short type = this.getNodeType(); switch (type) { case Node.ELEMENT_NODE: { String namespace = this.getNamespaceURI(); // to flip out children return lookupNamespacePrefix(namespaceURI, (ElementImpl)this); } case Node.DOCUMENT_NODE:{ return((NodeImpl)((Document)this).getDocumentElement()).lookupPrefix(namespaceURI); } case Node.ENTITY_NODE : case Node.NOTATION_NODE: case Node.DOCUMENT_FRAGMENT_NODE: case Node.DOCUMENT_TYPE_NODE: // type is unknown return null; case Node.ATTRIBUTE_NODE:{ if (this.ownerNode.getNodeType() == Node.ELEMENT_NODE) { return ownerNode.lookupPrefix(namespaceURI); } return null; } default:{ NodeImpl ancestor = (NodeImpl)getElementAncestor(this); if (ancestor != null) { return ancestor.lookupPrefix(namespaceURI); } return null; } } }
Example 15
Source File: DTMNodeProxy.java From jdk1.8-source-analysis with Apache License 2.0 | 4 votes |
/** * * DOM Level 3 * Look up the prefix associated to the given namespace URI, starting from this node. * * @param namespaceURI * @return the prefix for the namespace */ @Override public String lookupPrefix(String namespaceURI){ // REVISIT: When Namespaces 1.1 comes out this may not be true // Prefix can't be bound to null namespace if (namespaceURI == null) { return null; } short type = this.getNodeType(); switch (type) { /* case Node.ELEMENT_NODE: { String namespace = this.getNamespaceURI(); // to flip out children return lookupNamespacePrefix(namespaceURI, (ElementImpl)this); } case Node.DOCUMENT_NODE:{ return((NodeImpl)((Document)this).getDocumentElement()).lookupPrefix(namespaceURI); } */ case Node.ENTITY_NODE : case Node.NOTATION_NODE: case Node.DOCUMENT_FRAGMENT_NODE: case Node.DOCUMENT_TYPE_NODE: // type is unknown return null; case Node.ATTRIBUTE_NODE:{ if (this.getOwnerElement().getNodeType() == Node.ELEMENT_NODE) { return getOwnerElement().lookupPrefix(namespaceURI); } return null; } default:{ /* NodeImpl ancestor = (NodeImpl)getElementAncestor(this); if (ancestor != null) { return ancestor.lookupPrefix(namespaceURI); } */ return null; } } }
Example 16
Source File: NodeImpl.java From jdk1.8-source-analysis with Apache License 2.0 | 4 votes |
/** * * DOM Level 3 - Experimental: * Look up the prefix associated to the given namespace URI, starting from this node. * * @param namespaceURI * @return the prefix for the namespace */ public String lookupPrefix(String namespaceURI){ // REVISIT: When Namespaces 1.1 comes out this may not be true // Prefix can't be bound to null namespace if (namespaceURI == null) { return null; } short type = this.getNodeType(); switch (type) { case Node.ELEMENT_NODE: { String namespace = this.getNamespaceURI(); // to flip out children return lookupNamespacePrefix(namespaceURI, (ElementImpl)this); } case Node.DOCUMENT_NODE:{ return((NodeImpl)((Document)this).getDocumentElement()).lookupPrefix(namespaceURI); } case Node.ENTITY_NODE : case Node.NOTATION_NODE: case Node.DOCUMENT_FRAGMENT_NODE: case Node.DOCUMENT_TYPE_NODE: // type is unknown return null; case Node.ATTRIBUTE_NODE:{ if (this.ownerNode.getNodeType() == Node.ELEMENT_NODE) { return ownerNode.lookupPrefix(namespaceURI); } return null; } default:{ NodeImpl ancestor = (NodeImpl)getElementAncestor(this); if (ancestor != null) { return ancestor.lookupPrefix(namespaceURI); } return null; } } }
Example 17
Source File: UnImplNode.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
/** * * DOM Level 3 - Experimental: * Look up the prefix associated to the given namespace URI, starting from this node. * * @param namespaceURI * @return the prefix for the namespace */ public String lookupPrefix(String namespaceURI){ // REVISIT: When Namespaces 1.1 comes out this may not be true // Prefix can't be bound to null namespace if (namespaceURI == null) { return null; } short type = this.getNodeType(); switch (type) { /* case Node.ELEMENT_NODE: { String namespace = this.getNamespaceURI(); // to flip out children return lookupNamespacePrefix(namespaceURI, (ElementImpl)this); } case Node.DOCUMENT_NODE:{ return((NodeImpl)((Document)this).getDocumentElement()).lookupPrefix(namespaceURI); } */ case Node.ENTITY_NODE : case Node.NOTATION_NODE: case Node.DOCUMENT_FRAGMENT_NODE: case Node.DOCUMENT_TYPE_NODE: // type is unknown return null; case Node.ATTRIBUTE_NODE:{ if (this.getOwnerElement().getNodeType() == Node.ELEMENT_NODE) { return getOwnerElement().lookupPrefix(namespaceURI); } return null; } default:{ /* NodeImpl ancestor = (NodeImpl)getElementAncestor(this); if (ancestor != null) { return ancestor.lookupPrefix(namespaceURI); } */ return null; } } }
Example 18
Source File: RangeImpl.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
public void surroundContents(Node newParent) throws DOMException, RangeException { if (newParent==null) return; int type = newParent.getNodeType(); if (fDocument.errorChecking) { if (fDetach) { throw new DOMException( DOMException.INVALID_STATE_ERR, DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INVALID_STATE_ERR", null)); } if (type == Node.ATTRIBUTE_NODE || type == Node.ENTITY_NODE || type == Node.NOTATION_NODE || type == Node.DOCUMENT_TYPE_NODE || type == Node.DOCUMENT_NODE || type == Node.DOCUMENT_FRAGMENT_NODE) { throw new RangeExceptionImpl( RangeException.INVALID_NODE_TYPE_ERR, DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INVALID_NODE_TYPE_ERR", null)); } } Node realStart = fStartContainer; Node realEnd = fEndContainer; if (fStartContainer.getNodeType() == Node.TEXT_NODE) { realStart = fStartContainer.getParentNode(); } if (fEndContainer.getNodeType() == Node.TEXT_NODE) { realEnd = fEndContainer.getParentNode(); } if (realStart != realEnd) { throw new RangeExceptionImpl( RangeException.BAD_BOUNDARYPOINTS_ERR, DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "BAD_BOUNDARYPOINTS_ERR", null)); } DocumentFragment frag = extractContents(); insertNode(newParent); newParent.appendChild(frag); selectNode(newParent); }
Example 19
Source File: UnImplNode.java From Bytecoder with Apache License 2.0 | 4 votes |
/** * * DOM Level 3 - Experimental: * Look up the prefix associated to the given namespace URI, starting from this node. * * @param namespaceURI * @return the prefix for the namespace */ public String lookupPrefix(String namespaceURI){ // REVISIT: When Namespaces 1.1 comes out this may not be true // Prefix can't be bound to null namespace if (namespaceURI == null) { return null; } short type = this.getNodeType(); switch (type) { /* case Node.ELEMENT_NODE: { String namespace = this.getNamespaceURI(); // to flip out children return lookupNamespacePrefix(namespaceURI, (ElementImpl)this); } case Node.DOCUMENT_NODE:{ return((NodeImpl)((Document)this).getDocumentElement()).lookupPrefix(namespaceURI); } */ case Node.ENTITY_NODE : case Node.NOTATION_NODE: case Node.DOCUMENT_FRAGMENT_NODE: case Node.DOCUMENT_TYPE_NODE: // type is unknown return null; case Node.ATTRIBUTE_NODE:{ if (this.getOwnerElement().getNodeType() == Node.ELEMENT_NODE) { return getOwnerElement().lookupPrefix(namespaceURI); } return null; } default:{ /* NodeImpl ancestor = (NodeImpl)getElementAncestor(this); if (ancestor != null) { return ancestor.lookupPrefix(namespaceURI); } */ return null; } } }
Example 20
Source File: DTMNodeProxy.java From hottub with GNU General Public License v2.0 | 4 votes |
/** * DOM Level 3 * Look up the namespace URI associated to the given prefix, starting from this node. * Use lookupNamespaceURI(null) to lookup the default namespace * * @param namespaceURI * @return th URI for the namespace * @since DOM Level 3 */ @Override public String lookupNamespaceURI(String specifiedPrefix) { short type = this.getNodeType(); switch (type) { case Node.ELEMENT_NODE : { String namespace = this.getNamespaceURI(); String prefix = this.getPrefix(); if (namespace !=null) { // REVISIT: is it possible that prefix is empty string? if (specifiedPrefix== null && prefix==specifiedPrefix) { // looking for default namespace return namespace; } else if (prefix != null && prefix.equals(specifiedPrefix)) { // non default namespace return namespace; } } if (this.hasAttributes()) { NamedNodeMap map = this.getAttributes(); int length = map.getLength(); for (int i=0;i<length;i++) { Node attr = map.item(i); String attrPrefix = attr.getPrefix(); String value = attr.getNodeValue(); namespace = attr.getNamespaceURI(); if (namespace !=null && namespace.equals("http://www.w3.org/2000/xmlns/")) { // at this point we are dealing with DOM Level 2 nodes only if (specifiedPrefix == null && attr.getNodeName().equals("xmlns")) { // default namespace return value; } else if (attrPrefix !=null && attrPrefix.equals("xmlns") && attr.getLocalName().equals(specifiedPrefix)) { // non default namespace return value; } } } } /* NodeImpl ancestor = (NodeImpl)getElementAncestor(this); if (ancestor != null) { return ancestor.lookupNamespaceURI(specifiedPrefix); } */ return null; } /* case Node.DOCUMENT_NODE : { return((NodeImpl)((Document)this).getDocumentElement()).lookupNamespaceURI(specifiedPrefix) ; } */ case Node.ENTITY_NODE : case Node.NOTATION_NODE: case Node.DOCUMENT_FRAGMENT_NODE: case Node.DOCUMENT_TYPE_NODE: // type is unknown return null; case Node.ATTRIBUTE_NODE:{ if (this.getOwnerElement().getNodeType() == Node.ELEMENT_NODE) { return getOwnerElement().lookupNamespaceURI(specifiedPrefix); } return null; } default:{ /* NodeImpl ancestor = (NodeImpl)getElementAncestor(this); if (ancestor != null) { return ancestor.lookupNamespaceURI(specifiedPrefix); } */ return null; } } }