dom2dtmdefaultnamespacedeclarationnode.java
来自「JAVA 所有包」· Java 代码 · 共 678 行 · 第 1/2 页
JAVA
678 行
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; } } } /** * DOM Level 3: Experimental * This method checks if the specified <code>namespaceURI</code> is the * default namespace or not. * @param namespaceURI The namespace URI to look for. * @return <code>true</code> if the specified <code>namespaceURI</code> * is the default namespace, <code>false</code> otherwise. * @since DOM Level 3 */ public boolean isDefaultNamespace(String namespaceURI){ /* // REVISIT: remove casts when DOM L3 becomes REC. short type = this.getNodeType(); switch (type) { case Node.ELEMENT_NODE: { String namespace = this.getNamespaceURI(); String prefix = this.getPrefix(); // REVISIT: is it possible that prefix is empty string? if (prefix == null || prefix.length() == 0) { if (namespaceURI == null) { return (namespace == namespaceURI); } return namespaceURI.equals(namespace); } if (this.hasAttributes()) { ElementImpl elem = (ElementImpl)this; NodeImpl attr = (NodeImpl)elem.getAttributeNodeNS("http://www.w3.org/2000/xmlns/", "xmlns"); if (attr != null) { String value = attr.getNodeValue(); if (namespaceURI == null) { return (namespace == value); } return namespaceURI.equals(value); } } NodeImpl ancestor = (NodeImpl)getElementAncestor(this); if (ancestor != null) { return ancestor.isDefaultNamespace(namespaceURI); } return false; } case Node.DOCUMENT_NODE:{ return((NodeImpl)((Document)this).getDocumentElement()).isDefaultNamespace(namespaceURI); } case Node.ENTITY_NODE : case Node.NOTATION_NODE: case Node.DOCUMENT_FRAGMENT_NODE: case Node.DOCUMENT_TYPE_NODE: // type is unknown return false; case Node.ATTRIBUTE_NODE:{ if (this.ownerNode.getNodeType() == Node.ELEMENT_NODE) { return ownerNode.isDefaultNamespace(namespaceURI); } return false; } default:{ NodeImpl ancestor = (NodeImpl)getElementAncestor(this); if (ancestor != null) { return ancestor.isDefaultNamespace(namespaceURI); } return false; } }*/ return false; } /** * * 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; } } } /** * Returns whether this node is the same node as the given one. * <br>This method provides a way to determine whether two * <code>Node</code> references returned by the implementation reference * the same object. When two <code>Node</code> references are references * to the same object, even if through a proxy, the references may be * used completely interchangably, such that all attributes have the * same values and calling the same DOM method on either reference * always has exactly the same effect. * @param other The node to test against. * @return Returns <code>true</code> if the nodes are the same, * <code>false</code> otherwise. * @since DOM Level 3 */ public boolean isSameNode(Node other) { // we do not use any wrapper so the answer is obvious return this == other; } /** * This attribute returns the text content of this node and its * descendants. When it is defined to be null, setting it has no effect. * When set, any possible children this node may have are removed and * replaced by a single <code>Text</code> node containing the string * this attribute is set to. On getting, no serialization is performed, * the returned string does not contain any markup. No whitespace * normalization is performed, the returned string does not contain the * element content whitespaces . Similarly, on setting, no parsing is * performed either, the input string is taken as pure textual content. * <br>The string returned is made of the text content of this node * depending on its type, as defined below: * <table border='1'> * <tr> * <th>Node type</th> * <th>Content</th> * </tr> * <tr> * <td valign='top' rowspan='1' colspan='1'> * ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, * DOCUMENT_FRAGMENT_NODE</td> * <td valign='top' rowspan='1' colspan='1'>concatenation of the <code>textContent</code> * attribute value of every child node, excluding COMMENT_NODE and * PROCESSING_INSTRUCTION_NODE nodes</td> * </tr> * <tr> * <td valign='top' rowspan='1' colspan='1'>ATTRIBUTE_NODE, TEXT_NODE, * CDATA_SECTION_NODE, COMMENT_NODE, PROCESSING_INSTRUCTION_NODE</td> * <td valign='top' rowspan='1' colspan='1'> * <code>nodeValue</code></td> * </tr> * <tr> * <td valign='top' rowspan='1' colspan='1'>DOCUMENT_NODE, DOCUMENT_TYPE_NODE, NOTATION_NODE</td> * <td valign='top' rowspan='1' colspan='1'> * null</td> * </tr> * </table> * @exception DOMException * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly. * @exception DOMException * DOMSTRING_SIZE_ERR: Raised when it would return more characters than * fit in a <code>DOMString</code> variable on the implementation * platform. * @since DOM Level 3 */ public void setTextContent(String textContent) throws DOMException { setNodeValue(textContent); } /** * This attribute returns the text content of this node and its * descendants. When it is defined to be null, setting it has no effect. * When set, any possible children this node may have are removed and * replaced by a single <code>Text</code> node containing the string * this attribute is set to. On getting, no serialization is performed, * the returned string does not contain any markup. No whitespace * normalization is performed, the returned string does not contain the * element content whitespaces . Similarly, on setting, no parsing is * performed either, the input string is taken as pure textual content. * <br>The string returned is made of the text content of this node * depending on its type, as defined below: * <table border='1'> * <tr> * <th>Node type</th> * <th>Content</th> * </tr> * <tr> * <td valign='top' rowspan='1' colspan='1'> * ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, * DOCUMENT_FRAGMENT_NODE</td> * <td valign='top' rowspan='1' colspan='1'>concatenation of the <code>textContent</code> * attribute value of every child node, excluding COMMENT_NODE and * PROCESSING_INSTRUCTION_NODE nodes</td> * </tr> * <tr> * <td valign='top' rowspan='1' colspan='1'>ATTRIBUTE_NODE, TEXT_NODE, * CDATA_SECTION_NODE, COMMENT_NODE, PROCESSING_INSTRUCTION_NODE</td> * <td valign='top' rowspan='1' colspan='1'> * <code>nodeValue</code></td> * </tr> * <tr> * <td valign='top' rowspan='1' colspan='1'>DOCUMENT_NODE, DOCUMENT_TYPE_NODE, NOTATION_NODE</td> * <td valign='top' rowspan='1' colspan='1'> * null</td> * </tr> * </table> * @exception DOMException * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly. * @exception DOMException * DOMSTRING_SIZE_ERR: Raised when it would return more characters than * fit in a <code>DOMString</code> variable on the implementation * platform. * @since DOM Level 3 */ public String getTextContent() throws DOMException { return getNodeValue(); // overriden in some subclasses } /** * Compares a node with this node with regard to their position in the * document. * @param other The node to compare against this node. * @return Returns how the given node is positioned relatively to this * node. * @since DOM Level 3 */ public short compareDocumentPosition(Node other) throws DOMException { return 0; } /** * The absolute base URI of this node or <code>null</code> if undefined. * This value is computed according to . However, when the * <code>Document</code> supports the feature "HTML" , the base URI is * computed using first the value of the href attribute of the HTML BASE * element if any, and the value of the <code>documentURI</code> * attribute from the <code>Document</code> interface otherwise. * <br> When the node is an <code>Element</code>, a <code>Document</code> * or a a <code>ProcessingInstruction</code>, this attribute represents * the properties [base URI] defined in . When the node is a * <code>Notation</code>, an <code>Entity</code>, or an * <code>EntityReference</code>, this attribute represents the * properties [declaration base URI] in the . How will this be affected * by resolution of relative namespace URIs issue?It's not.Should this * only be on Document, Element, ProcessingInstruction, Entity, and * Notation nodes, according to the infoset? If not, what is it equal to * on other nodes? Null? An empty string? I think it should be the * parent's.No.Should this be read-only and computed or and actual * read-write attribute?Read-only and computed (F2F 19 Jun 2000 and * teleconference 30 May 2001).If the base HTML element is not yet * attached to a document, does the insert change the Document.baseURI? * Yes. (F2F 26 Sep 2001) * @since DOM Level 3 */ public String getBaseURI() { return null; }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?