Path: blob/master/src/java.xml/share/classes/org/w3c/dom/Node.java
40948 views
/*1* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.2*3* This code is free software; you can redistribute it and/or modify it4* under the terms of the GNU General Public License version 2 only, as5* published by the Free Software Foundation. Oracle designates this6* particular file as subject to the "Classpath" exception as provided7* by Oracle in the LICENSE file that accompanied this code.8*9* This code is distributed in the hope that it will be useful, but WITHOUT10* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or11* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License12* version 2 for more details (a copy is included in the LICENSE file that13* accompanied this code).14*15* You should have received a copy of the GNU General Public License version16* 2 along with this work; if not, write to the Free Software Foundation,17* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.18*19* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA20* or visit www.oracle.com if you need additional information or have any21* questions.22*/2324/*25* This file is available under and governed by the GNU General Public26* License version 2 only, as published by the Free Software Foundation.27* However, the following notice accompanied the original version of this28* file and, per its terms, should not be removed:29*30* Copyright (c) 2004 World Wide Web Consortium,31*32* (Massachusetts Institute of Technology, European Research Consortium for33* Informatics and Mathematics, Keio University). All Rights Reserved. This34* work is distributed under the W3C(r) Software License [1] in the hope that35* it will be useful, but WITHOUT ANY WARRANTY; without even the implied36* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.37*38* [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-2002123139*/4041package org.w3c.dom;4243/**44* The <code>Node</code> interface is the primary datatype for the entire45* Document Object Model. It represents a single node in the document tree.46* While all objects implementing the <code>Node</code> interface expose47* methods for dealing with children, not all objects implementing the48* <code>Node</code> interface may have children. For example,49* <code>Text</code> nodes may not have children, and adding children to50* such nodes results in a <code>DOMException</code> being raised.51* <p>The attributes <code>nodeName</code>, <code>nodeValue</code> and52* <code>attributes</code> are included as a mechanism to get at node53* information without casting down to the specific derived interface. In54* cases where there is no obvious mapping of these attributes for a55* specific <code>nodeType</code> (e.g., <code>nodeValue</code> for an56* <code>Element</code> or <code>attributes</code> for a <code>Comment</code>57* ), this returns <code>null</code>. Note that the specialized interfaces58* may contain additional and more convenient mechanisms to get and set the59* relevant information.60* <p>The values of <code>nodeName</code>,61* <code>nodeValue</code>, and <code>attributes</code> vary according to the62* node type as follows:63* <table class="striped">64* <caption style="display:none">Interface table</caption>65* <thead>66* <tr>67* <th scope="col">Interface</th>68* <th scope="col">nodeName</th>69* <th scope="col">nodeValue</th>70* <th scope="col">attributes</th>71* </tr>72* </thead>73* <tbody>74* <tr>75* <th scope="row">76* <code>Attr</code></th>77* <td>same as <code>Attr.name</code></td>78* <td>same as79* <code>Attr.value</code></td>80* <td><code>null</code></td>81* </tr>82* <tr>83* <th scope="row"><code>CDATASection</code></th>84* <td>85* <code>"#cdata-section"</code></td>86* <td>same as <code>CharacterData.data</code>, the87* content of the CDATA Section</td>88* <td><code>null</code></td>89* </tr>90* <tr>91* <th scope="row"><code>Comment</code></th>92* <td>93* <code>"#comment"</code></td>94* <td>same as <code>CharacterData.data</code>, the95* content of the comment</td>96* <td><code>null</code></td>97* </tr>98* <tr>99* <th scope="row"><code>Document</code></th>100* <td>101* <code>"#document"</code></td>102* <td><code>null</code></td>103* <td><code>null</code></td>104* </tr>105* <tr>106* <th scope="row">107* <code>DocumentFragment</code></th>108* <td><code>"#document-fragment"</code></td>109* <td>110* <code>null</code></td>111* <td><code>null</code></td>112* </tr>113* <tr>114* <th scope="row"><code>DocumentType</code></th>115* <td>same as116* <code>DocumentType.name</code></td>117* <td><code>null</code></td>118* <td><code>null</code></td>119* </tr>120* <tr>121* <th scope="row">122* <code>Element</code></th>123* <td>same as <code>Element.tagName</code></td>124* <td><code>null</code></td>125* <td>126* <code>NamedNodeMap</code></td>127* </tr>128* <tr>129* <th scope="row"><code>Entity</code></th>130* <td>entity name</td>131* <td><code>null</code></td>132* <td>133* <code>null</code></td>134* </tr>135* <tr>136* <th scope="row"><code>EntityReference</code></th>137* <td>name of entity referenced</td>138* <td>139* <code>null</code></td>140* <td><code>null</code></td>141* </tr>142* <tr>143* <th scope="row"><code>Notation</code></th>144* <td>notation name</td>145* <td>146* <code>null</code></td>147* <td><code>null</code></td>148* </tr>149* <tr>150* <th scope="row"><code>ProcessingInstruction</code></th>151* <td>same152* as <code>ProcessingInstruction.target</code></td>153* <td>same as154* <code>ProcessingInstruction.data</code></td>155* <td><code>null</code></td>156* </tr>157* <tr>158* <th scope="row"><code>Text</code></th>159* <td>160* <code>"#text"</code></td>161* <td>same as <code>CharacterData.data</code>, the content162* of the text node</td>163* <td><code>null</code></td>164* </tr>165* </tbody>166* </table>167* <p>See also the <a href='http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407'>Document Object Model (DOM) Level 3 Core Specification</a>.168*/169public interface Node {170// NodeType171/**172* The node is an <code>Element</code>.173*/174public static final short ELEMENT_NODE = 1;175/**176* The node is an <code>Attr</code>.177*/178public static final short ATTRIBUTE_NODE = 2;179/**180* The node is a <code>Text</code> node.181*/182public static final short TEXT_NODE = 3;183/**184* The node is a <code>CDATASection</code>.185*/186public static final short CDATA_SECTION_NODE = 4;187/**188* The node is an <code>EntityReference</code>.189*/190public static final short ENTITY_REFERENCE_NODE = 5;191/**192* The node is an <code>Entity</code>.193*/194public static final short ENTITY_NODE = 6;195/**196* The node is a <code>ProcessingInstruction</code>.197*/198public static final short PROCESSING_INSTRUCTION_NODE = 7;199/**200* The node is a <code>Comment</code>.201*/202public static final short COMMENT_NODE = 8;203/**204* The node is a <code>Document</code>.205*/206public static final short DOCUMENT_NODE = 9;207/**208* The node is a <code>DocumentType</code>.209*/210public static final short DOCUMENT_TYPE_NODE = 10;211/**212* The node is a <code>DocumentFragment</code>.213*/214public static final short DOCUMENT_FRAGMENT_NODE = 11;215/**216* The node is a <code>Notation</code>.217*/218public static final short NOTATION_NODE = 12;219220/**221* The name of this node, depending on its type; see the table above.222*/223public String getNodeName();224225/**226* The value of this node, depending on its type; see the table above.227* When it is defined to be <code>null</code>, setting it has no effect,228* including if the node is read-only.229* @exception DOMException230* DOMSTRING_SIZE_ERR: Raised when it would return more characters than231* fit in a <code>DOMString</code> variable on the implementation232* platform.233*/234public String getNodeValue()235throws DOMException;236/**237* The value of this node, depending on its type; see the table above.238* When it is defined to be <code>null</code>, setting it has no effect,239* including if the node is read-only.240* @exception DOMException241* NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly and if242* it is not defined to be <code>null</code>.243*/244public void setNodeValue(String nodeValue)245throws DOMException;246247/**248* A code representing the type of the underlying object, as defined above.249*/250public short getNodeType();251252/**253* The parent of this node. All nodes, except <code>Attr</code>,254* <code>Document</code>, <code>DocumentFragment</code>,255* <code>Entity</code>, and <code>Notation</code> may have a parent.256* However, if a node has just been created and not yet added to the257* tree, or if it has been removed from the tree, this is258* <code>null</code>.259*/260public Node getParentNode();261262/**263* A <code>NodeList</code> that contains all children of this node. If264* there are no children, this is a <code>NodeList</code> containing no265* nodes.266*/267public NodeList getChildNodes();268269/**270* The first child of this node. If there is no such node, this returns271* <code>null</code>.272*/273public Node getFirstChild();274275/**276* The last child of this node. If there is no such node, this returns277* <code>null</code>.278*/279public Node getLastChild();280281/**282* The node immediately preceding this node. If there is no such node,283* this returns <code>null</code>.284*/285public Node getPreviousSibling();286287/**288* The node immediately following this node. If there is no such node,289* this returns <code>null</code>.290*/291public Node getNextSibling();292293/**294* A <code>NamedNodeMap</code> containing the attributes of this node (if295* it is an <code>Element</code>) or <code>null</code> otherwise.296*/297public NamedNodeMap getAttributes();298299/**300* The <code>Document</code> object associated with this node. This is301* also the <code>Document</code> object used to create new nodes. When302* this node is a <code>Document</code> or a <code>DocumentType</code>303* which is not used with any <code>Document</code> yet, this is304* <code>null</code>.305*306* @since 1.4, DOM Level 2307*/308public Document getOwnerDocument();309310/**311* Inserts the node <code>newChild</code> before the existing child node312* <code>refChild</code>. If <code>refChild</code> is <code>null</code>,313* insert <code>newChild</code> at the end of the list of children.314* <br>If <code>newChild</code> is a <code>DocumentFragment</code> object,315* all of its children are inserted, in the same order, before316* <code>refChild</code>. If the <code>newChild</code> is already in the317* tree, it is first removed.318* <p ><b>Note:</b> Inserting a node before itself is implementation319* dependent.320* @param newChild The node to insert.321* @param refChild The reference node, i.e., the node before which the322* new node must be inserted.323* @return The node being inserted.324* @exception DOMException325* HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not326* allow children of the type of the <code>newChild</code> node, or if327* the node to insert is one of this node's ancestors or this node328* itself, or if this node is of type <code>Document</code> and the329* DOM application attempts to insert a second330* <code>DocumentType</code> or <code>Element</code> node.331* <br>WRONG_DOCUMENT_ERR: Raised if <code>newChild</code> was created332* from a different document than the one that created this node.333* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly or334* if the parent of the node being inserted is readonly.335* <br>NOT_FOUND_ERR: Raised if <code>refChild</code> is not a child of336* this node.337* <br>NOT_SUPPORTED_ERR: if this node is of type <code>Document</code>,338* this exception might be raised if the DOM implementation doesn't339* support the insertion of a <code>DocumentType</code> or340* <code>Element</code> node.341*342* @since 1.4, DOM Level 3343*/344public Node insertBefore(Node newChild,345Node refChild)346throws DOMException;347348/**349* Replaces the child node <code>oldChild</code> with <code>newChild</code>350* in the list of children, and returns the <code>oldChild</code> node.351* <br>If <code>newChild</code> is a <code>DocumentFragment</code> object,352* <code>oldChild</code> is replaced by all of the353* <code>DocumentFragment</code> children, which are inserted in the354* same order. If the <code>newChild</code> is already in the tree, it355* is first removed.356* <p ><b>Note:</b> Replacing a node with itself is implementation357* dependent.358* @param newChild The new node to put in the child list.359* @param oldChild The node being replaced in the list.360* @return The node replaced.361* @exception DOMException362* HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not363* allow children of the type of the <code>newChild</code> node, or if364* the node to put in is one of this node's ancestors or this node365* itself, or if this node is of type <code>Document</code> and the366* result of the replacement operation would add a second367* <code>DocumentType</code> or <code>Element</code> on the368* <code>Document</code> node.369* <br>WRONG_DOCUMENT_ERR: Raised if <code>newChild</code> was created370* from a different document than the one that created this node.371* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node or the parent of372* the new node is readonly.373* <br>NOT_FOUND_ERR: Raised if <code>oldChild</code> is not a child of374* this node.375* <br>NOT_SUPPORTED_ERR: if this node is of type <code>Document</code>,376* this exception might be raised if the DOM implementation doesn't377* support the replacement of the <code>DocumentType</code> child or378* <code>Element</code> child.379*380* @since 1.4, DOM Level 3381*/382public Node replaceChild(Node newChild,383Node oldChild)384throws DOMException;385386/**387* Removes the child node indicated by <code>oldChild</code> from the list388* of children, and returns it.389* @param oldChild The node being removed.390* @return The node removed.391* @exception DOMException392* NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.393* <br>NOT_FOUND_ERR: Raised if <code>oldChild</code> is not a child of394* this node.395* <br>NOT_SUPPORTED_ERR: if this node is of type <code>Document</code>,396* this exception might be raised if the DOM implementation doesn't397* support the removal of the <code>DocumentType</code> child or the398* <code>Element</code> child.399*400* @since 1.4, DOM Level 3401*/402public Node removeChild(Node oldChild)403throws DOMException;404405/**406* Adds the node <code>newChild</code> to the end of the list of children407* of this node. If the <code>newChild</code> is already in the tree, it408* is first removed.409* @param newChild The node to add.If it is a410* <code>DocumentFragment</code> object, the entire contents of the411* document fragment are moved into the child list of this node412* @return The node added.413* @exception DOMException414* HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not415* allow children of the type of the <code>newChild</code> node, or if416* the node to append is one of this node's ancestors or this node417* itself, or if this node is of type <code>Document</code> and the418* DOM application attempts to append a second419* <code>DocumentType</code> or <code>Element</code> node.420* <br>WRONG_DOCUMENT_ERR: Raised if <code>newChild</code> was created421* from a different document than the one that created this node.422* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly or423* if the previous parent of the node being inserted is readonly.424* <br>NOT_SUPPORTED_ERR: if the <code>newChild</code> node is a child425* of the <code>Document</code> node, this exception might be raised426* if the DOM implementation doesn't support the removal of the427* <code>DocumentType</code> child or <code>Element</code> child.428*429* @since 1.4, DOM Level 3430*/431public Node appendChild(Node newChild)432throws DOMException;433434/**435* Returns whether this node has any children.436* @return Returns <code>true</code> if this node has any children,437* <code>false</code> otherwise.438*/439public boolean hasChildNodes();440441/**442* Returns a duplicate of this node, i.e., serves as a generic copy443* constructor for nodes. The duplicate node has no parent (444* <code>parentNode</code> is <code>null</code>) and no user data. User445* data associated to the imported node is not carried over. However, if446* any <code>UserDataHandlers</code> has been specified along with the447* associated data these handlers will be called with the appropriate448* parameters before this method returns.449* <br>Cloning an <code>Element</code> copies all attributes and their450* values, including those generated by the XML processor to represent451* defaulted attributes, but this method does not copy any children it452* contains unless it is a deep clone. This includes text contained in453* an the <code>Element</code> since the text is contained in a child454* <code>Text</code> node. Cloning an <code>Attr</code> directly, as455* opposed to be cloned as part of an <code>Element</code> cloning456* operation, returns a specified attribute (<code>specified</code> is457* <code>true</code>). Cloning an <code>Attr</code> always clones its458* children, since they represent its value, no matter whether this is a459* deep clone or not. Cloning an <code>EntityReference</code>460* automatically constructs its subtree if a corresponding461* <code>Entity</code> is available, no matter whether this is a deep462* clone or not. Cloning any other type of node simply returns a copy of463* this node.464* <br>Note that cloning an immutable subtree results in a mutable copy,465* but the children of an <code>EntityReference</code> clone are readonly466* . In addition, clones of unspecified <code>Attr</code> nodes are467* specified. And, cloning <code>Document</code>,468* <code>DocumentType</code>, <code>Entity</code>, and469* <code>Notation</code> nodes is implementation dependent.470* @param deep If <code>true</code>, recursively clone the subtree under471* the specified node; if <code>false</code>, clone only the node472* itself (and its attributes, if it is an <code>Element</code>).473* @return The duplicate node.474*/475public Node cloneNode(boolean deep);476477/**478* Puts all <code>Text</code> nodes in the full depth of the sub-tree479* underneath this <code>Node</code>, including attribute nodes, into a480* "normal" form where only structure (e.g., elements, comments,481* processing instructions, CDATA sections, and entity references)482* separates <code>Text</code> nodes, i.e., there are neither adjacent483* <code>Text</code> nodes nor empty <code>Text</code> nodes. This can484* be used to ensure that the DOM view of a document is the same as if485* it were saved and re-loaded, and is useful when operations (such as486* XPointer [<a href='http://www.w3.org/TR/2003/REC-xptr-framework-20030325/'>XPointer</a>]487* lookups) that depend on a particular document tree structure are to488* be used. If the parameter "normalize-characters" of the489* <code>DOMConfiguration</code> object attached to the490* <code>Node.ownerDocument</code> is <code>true</code>, this method491* will also fully normalize the characters of the <code>Text</code>492* nodes.493* <p ><b>Note:</b> In cases where the document contains494* <code>CDATASections</code>, the normalize operation alone may not be495* sufficient, since XPointers do not differentiate between496* <code>Text</code> nodes and <code>CDATASection</code> nodes.497*498* @since 1.4, DOM Level 3499*/500public void normalize();501502/**503* Tests whether the DOM implementation implements a specific feature and504* that feature is supported by this node, as specified in .505* @param feature The name of the feature to test.506* @param version This is the version number of the feature to test.507* @return Returns <code>true</code> if the specified feature is508* supported on this node, <code>false</code> otherwise.509*510* @since 1.4, DOM Level 2511*/512public boolean isSupported(String feature,513String version);514515/**516* The namespace URI of this node, or <code>null</code> if it is517* unspecified (see ).518* <br>This is not a computed value that is the result of a namespace519* lookup based on an examination of the namespace declarations in520* scope. It is merely the namespace URI given at creation time.521* <br>For nodes of any type other than <code>ELEMENT_NODE</code> and522* <code>ATTRIBUTE_NODE</code> and nodes created with a DOM Level 1523* method, such as <code>Document.createElement()</code>, this is always524* <code>null</code>.525* <p ><b>Note:</b> Per the <em>Namespaces in XML</em> Specification [<a href='http://www.w3.org/TR/1999/REC-xml-names-19990114/'>XML Namespaces</a>]526* an attribute does not inherit its namespace from the element it is527* attached to. If an attribute is not explicitly given a namespace, it528* simply has no namespace.529*530* @since 1.4, DOM Level 2531*/532public String getNamespaceURI();533534/**535* The namespace prefix of this node, or <code>null</code> if it is536* unspecified. When it is defined to be <code>null</code>, setting it537* has no effect, including if the node is read-only.538* <br>Note that setting this attribute, when permitted, changes the539* <code>nodeName</code> attribute, which holds the qualified name, as540* well as the <code>tagName</code> and <code>name</code> attributes of541* the <code>Element</code> and <code>Attr</code> interfaces, when542* applicable.543* <br>Setting the prefix to <code>null</code> makes it unspecified,544* setting it to an empty string is implementation dependent.545* <br>Note also that changing the prefix of an attribute that is known to546* have a default value, does not make a new attribute with the default547* value and the original prefix appear, since the548* <code>namespaceURI</code> and <code>localName</code> do not change.549* <br>For nodes of any type other than <code>ELEMENT_NODE</code> and550* <code>ATTRIBUTE_NODE</code> and nodes created with a DOM Level 1551* method, such as <code>createElement</code> from the552* <code>Document</code> interface, this is always <code>null</code>.553*554* @since 1.4, DOM Level 2555*/556public String getPrefix();557/**558* The namespace prefix of this node, or <code>null</code> if it is559* unspecified. When it is defined to be <code>null</code>, setting it560* has no effect, including if the node is read-only.561* <br>Note that setting this attribute, when permitted, changes the562* <code>nodeName</code> attribute, which holds the qualified name, as563* well as the <code>tagName</code> and <code>name</code> attributes of564* the <code>Element</code> and <code>Attr</code> interfaces, when565* applicable.566* <br>Setting the prefix to <code>null</code> makes it unspecified,567* setting it to an empty string is implementation dependent.568* <br>Note also that changing the prefix of an attribute that is known to569* have a default value, does not make a new attribute with the default570* value and the original prefix appear, since the571* <code>namespaceURI</code> and <code>localName</code> do not change.572* <br>For nodes of any type other than <code>ELEMENT_NODE</code> and573* <code>ATTRIBUTE_NODE</code> and nodes created with a DOM Level 1574* method, such as <code>createElement</code> from the575* <code>Document</code> interface, this is always <code>null</code>.576* @exception DOMException577* INVALID_CHARACTER_ERR: Raised if the specified prefix contains an578* illegal character according to the XML version in use specified in579* the <code>Document.xmlVersion</code> attribute.580* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.581* <br>NAMESPACE_ERR: Raised if the specified <code>prefix</code> is582* malformed per the Namespaces in XML specification, if the583* <code>namespaceURI</code> of this node is <code>null</code>, if the584* specified prefix is "xml" and the <code>namespaceURI</code> of this585* node is different from "<a href='http://www.w3.org/XML/1998/namespace'>586* http://www.w3.org/XML/1998/namespace</a>", if this node is an attribute and the specified prefix is "xmlns" and587* the <code>namespaceURI</code> of this node is different from "<a href='http://www.w3.org/2000/xmlns/'>http://www.w3.org/2000/xmlns/</a>", or if this node is an attribute and the <code>qualifiedName</code> of588* this node is "xmlns" [<a href='http://www.w3.org/TR/1999/REC-xml-names-19990114/'>XML Namespaces</a>]589* .590*591* @since 1.4, DOM Level 2592*/593public void setPrefix(String prefix)594throws DOMException;595596/**597* Returns the local part of the qualified name of this node.598* <br>For nodes of any type other than <code>ELEMENT_NODE</code> and599* <code>ATTRIBUTE_NODE</code> and nodes created with a DOM Level 1600* method, such as <code>Document.createElement()</code>, this is always601* <code>null</code>.602*603* @since 1.4, DOM Level 2604*/605public String getLocalName();606607/**608* Returns whether this node (if it is an element) has any attributes.609* @return Returns <code>true</code> if this node has any attributes,610* <code>false</code> otherwise.611*612* @since 1.4, DOM Level 2613*/614public boolean hasAttributes();615616/**617* The absolute base URI of this node or <code>null</code> if the618* implementation wasn't able to obtain an absolute URI. This value is619* computed as described in . However, when the <code>Document</code>620* supports the feature "HTML" [<a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>DOM Level 2 HTML</a>]621* , the base URI is computed using first the value of the href622* attribute of the HTML BASE element if any, and the value of the623* <code>documentURI</code> attribute from the <code>Document</code>624* interface otherwise.625*626* @since 1.5, DOM Level 3627*/628public String getBaseURI();629630// DocumentPosition631/**632* The two nodes are disconnected. Order between disconnected nodes is633* always implementation-specific.634*/635public static final short DOCUMENT_POSITION_DISCONNECTED = 0x01;636/**637* The second node precedes the reference node.638*/639public static final short DOCUMENT_POSITION_PRECEDING = 0x02;640/**641* The node follows the reference node.642*/643public static final short DOCUMENT_POSITION_FOLLOWING = 0x04;644/**645* The node contains the reference node. A node which contains is always646* preceding, too.647*/648public static final short DOCUMENT_POSITION_CONTAINS = 0x08;649/**650* The node is contained by the reference node. A node which is contained651* is always following, too.652*/653public static final short DOCUMENT_POSITION_CONTAINED_BY = 0x10;654/**655* The determination of preceding versus following is656* implementation-specific.657*/658public static final short DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20;659660/**661* Compares the reference node, i.e. the node on which this method is662* being called, with a node, i.e. the one passed as a parameter, with663* regard to their position in the document and according to the664* document order.665* @param other The node to compare against the reference node.666* @return Returns how the node is positioned relatively to the reference667* node.668* @exception DOMException669* NOT_SUPPORTED_ERR: when the compared nodes are from different DOM670* implementations that do not coordinate to return consistent671* implementation-specific results.672*673* @since 1.5, DOM Level 3674*/675public short compareDocumentPosition(Node other)676throws DOMException;677678/**679* This attribute returns the text content of this node and its680* descendants. When it is defined to be <code>null</code>, setting it681* has no effect. On setting, any possible children this node may have682* are removed and, if it the new string is not empty or683* <code>null</code>, replaced by a single <code>Text</code> node684* containing the string this attribute is set to.685* <br> On getting, no serialization is performed, the returned string686* does not contain any markup. No whitespace normalization is performed687* and the returned string does not contain the white spaces in element688* content (see the attribute689* <code>Text.isElementContentWhitespace</code>). Similarly, on setting,690* no parsing is performed either, the input string is taken as pure691* textual content.692* <br>The string returned is made of the text content of this node693* depending on its type, as defined below:694* <table class="striped">695* <caption style="display:none">Node/Content table</caption>696* <thead>697* <tr>698* <th scope="col">Node type</th>699* <th scope="col">Content</th>700* </tr>701* </thead>702* <tbody>703* <tr>704* <th scope="row">705* ELEMENT_NODE, ATTRIBUTE_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE,706* DOCUMENT_FRAGMENT_NODE</th>707* <td>concatenation of the <code>textContent</code>708* attribute value of every child node, excluding COMMENT_NODE and709* PROCESSING_INSTRUCTION_NODE nodes. This is the empty string if the710* node has no children.</td>711* </tr>712* <tr>713* <th scope="row">TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODE,714* PROCESSING_INSTRUCTION_NODE</th>715* <td><code>nodeValue</code></td>716* </tr>717* <tr>718* <th scope="row">DOCUMENT_NODE,719* DOCUMENT_TYPE_NODE, NOTATION_NODE</th>720* <td><em>null</em></td>721* </tr>722* </tbody>723* </table>724* @exception DOMException725* DOMSTRING_SIZE_ERR: Raised when it would return more characters than726* fit in a <code>DOMString</code> variable on the implementation727* platform.728*729* @since 1.5, DOM Level 3730*/731public String getTextContent()732throws DOMException;733/**734* This attribute returns the text content of this node and its735* descendants. When it is defined to be <code>null</code>, setting it736* has no effect. On setting, any possible children this node may have737* are removed and, if it the new string is not empty or738* <code>null</code>, replaced by a single <code>Text</code> node739* containing the string this attribute is set to.740* <br> On getting, no serialization is performed, the returned string741* does not contain any markup. No whitespace normalization is performed742* and the returned string does not contain the white spaces in element743* content (see the attribute744* <code>Text.isElementContentWhitespace</code>). Similarly, on setting,745* no parsing is performed either, the input string is taken as pure746* textual content.747* <br>The string returned is made of the text content of this node748* depending on its type, as defined below:749* <table class="striped">750* <caption style="display:none">Node/Content table</caption>751* <thead>752* <tr>753* <th scope="col">Node type</th>754* <th scope="col">Content</th>755* </tr>756* </thead>757* <tbody>758* <tr>759* <th scope="row">760* ELEMENT_NODE, ATTRIBUTE_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE,761* DOCUMENT_FRAGMENT_NODE</th>762* <td>concatenation of the <code>textContent</code>763* attribute value of every child node, excluding COMMENT_NODE and764* PROCESSING_INSTRUCTION_NODE nodes. This is the empty string if the765* node has no children.</td>766* </tr>767* <tr>768* <th scope="row">TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODE,769* PROCESSING_INSTRUCTION_NODE</th>770* <td><code>nodeValue</code></td>771* </tr>772* <tr>773* <th scope="row">DOCUMENT_NODE,774* DOCUMENT_TYPE_NODE, NOTATION_NODE</th>775* <td><em>null</em></td>776* </tr>777* </tbody>778* </table>779* @exception DOMException780* NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.781*782* @since 1.5, DOM Level 3783*/784public void setTextContent(String textContent)785throws DOMException;786787/**788* Returns whether this node is the same node as the given one.789* <br>This method provides a way to determine whether two790* <code>Node</code> references returned by the implementation reference791* the same object. When two <code>Node</code> references are references792* to the same object, even if through a proxy, the references may be793* used completely interchangeably, such that all attributes have the794* same values and calling the same DOM method on either reference795* always has exactly the same effect.796* @param other The node to test against.797* @return Returns <code>true</code> if the nodes are the same,798* <code>false</code> otherwise.799*800* @since 1.5, DOM Level 3801*/802public boolean isSameNode(Node other);803804/**805* Look up the prefix associated to the given namespace URI, starting from806* this node. The default namespace declarations are ignored by this807* method.808* <br>See for details on the algorithm used by this method.809* @param namespaceURI The namespace URI to look for.810* @return Returns an associated namespace prefix if found or811* <code>null</code> if none is found. If more than one prefix are812* associated to the namespace prefix, the returned namespace prefix813* is implementation dependent.814*815* @since 1.5, DOM Level 3816*/817public String lookupPrefix(String namespaceURI);818819/**820* This method checks if the specified <code>namespaceURI</code> is the821* default namespace or not.822* @param namespaceURI The namespace URI to look for.823* @return Returns <code>true</code> if the specified824* <code>namespaceURI</code> is the default namespace,825* <code>false</code> otherwise.826*827* @since 1.5, DOM Level 3828*/829public boolean isDefaultNamespace(String namespaceURI);830831/**832* Look up the namespace URI associated to the given prefix, starting from833* this node.834* <br>See for details on the algorithm used by this method.835* @param prefix The prefix to look for. If this parameter is836* <code>null</code>, the method will return the default namespace URI837* if any.838* @return Returns the associated namespace URI or <code>null</code> if839* none is found.840*841* @since 1.5, DOM Level 3842*/843public String lookupNamespaceURI(String prefix);844845/**846* Tests whether two nodes are equal.847* <br>This method tests for equality of nodes, not sameness (i.e.,848* whether the two nodes are references to the same object) which can be849* tested with <code>Node.isSameNode()</code>. All nodes that are the850* same will also be equal, though the reverse may not be true.851* <br>Two nodes are equal if and only if the following conditions are852* satisfied:853* <ul>854* <li>The two nodes are of the same type.855* </li>856* <li>The following string857* attributes are equal: <code>nodeName</code>, <code>localName</code>,858* <code>namespaceURI</code>, <code>prefix</code>, <code>nodeValue</code>859* . This is: they are both <code>null</code>, or they have the same860* length and are character for character identical.861* </li>862* <li>The863* <code>attributes</code> <code>NamedNodeMaps</code> are equal. This864* is: they are both <code>null</code>, or they have the same length and865* for each node that exists in one map there is a node that exists in866* the other map and is equal, although not necessarily at the same867* index.868* </li>869* <li>The <code>childNodes</code> <code>NodeLists</code> are equal.870* This is: they are both <code>null</code>, or they have the same871* length and contain equal nodes at the same index. Note that872* normalization can affect equality; to avoid this, nodes should be873* normalized before being compared.874* </li>875* </ul>876* <br>For two <code>DocumentType</code> nodes to be equal, the following877* conditions must also be satisfied:878* <ul>879* <li>The following string attributes880* are equal: <code>publicId</code>, <code>systemId</code>,881* <code>internalSubset</code>.882* </li>883* <li>The <code>entities</code>884* <code>NamedNodeMaps</code> are equal.885* </li>886* <li>The <code>notations</code>887* <code>NamedNodeMaps</code> are equal.888* </li>889* </ul>890* <br>On the other hand, the following do not affect equality: the891* <code>ownerDocument</code>, <code>baseURI</code>, and892* <code>parentNode</code> attributes, the <code>specified</code>893* attribute for <code>Attr</code> nodes, the <code>schemaTypeInfo</code>894* attribute for <code>Attr</code> and <code>Element</code> nodes, the895* <code>Text.isElementContentWhitespace</code> attribute for896* <code>Text</code> nodes, as well as any user data or event listeners897* registered on the nodes.898* <p ><b>Note:</b> As a general rule, anything not mentioned in the899* description above is not significant in consideration of equality900* checking. Note that future versions of this specification may take901* into account more attributes and implementations conform to this902* specification are expected to be updated accordingly.903* @param arg The node to compare equality with.904* @return Returns <code>true</code> if the nodes are equal,905* <code>false</code> otherwise.906*907* @since 1.5, DOM Level 3908*/909public boolean isEqualNode(Node arg);910911/**912* This method returns a specialized object which implements the913* specialized APIs of the specified feature and version, as specified914* in . The specialized object may also be obtained by using915* binding-specific casting methods but is not necessarily expected to,916* as discussed in . This method also allow the implementation to917* provide specialized objects which do not support the <code>Node</code>918* interface.919* @param feature The name of the feature requested. Note that any plus920* sign "+" prepended to the name of the feature will be ignored since921* it is not significant in the context of this method.922* @param version This is the version number of the feature to test.923* @return Returns an object which implements the specialized APIs of924* the specified feature and version, if any, or <code>null</code> if925* there is no object which implements interfaces associated with that926* feature. If the <code>DOMObject</code> returned by this method927* implements the <code>Node</code> interface, it must delegate to the928* primary core <code>Node</code> and not return results inconsistent929* with the primary core <code>Node</code> such as attributes,930* childNodes, etc.931*932* @since 1.5, DOM Level 3933*/934public Object getFeature(String feature,935String version);936937/**938* Associate an object to a key on this node. The object can later be939* retrieved from this node by calling <code>getUserData</code> with the940* same key.941* @param key The key to associate the object to.942* @param data The object to associate to the given key, or943* <code>null</code> to remove any existing association to that key.944* @param handler The handler to associate to that key, or945* <code>null</code>.946* @return Returns the <code>DOMUserData</code> previously associated to947* the given key on this node, or <code>null</code> if there was none.948*949* @since 1.5, DOM Level 3950*/951public Object setUserData(String key,952Object data,953UserDataHandler handler);954955/**956* Retrieves the object associated to a key on a this node. The object957* must first have been set to this node by calling958* <code>setUserData</code> with the same key.959* @param key The key the object is associated to.960* @return Returns the <code>DOMUserData</code> associated to the given961* key on this node, or <code>null</code> if there was none.962*963* @since 1.5, DOM Level 3964*/965public Object getUserData(String key);966967}968969970