1/* 2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * 4 * This code is free software; you can redistribute it and/or modify it 5 * under the terms of the GNU General Public License version 2 only, as 6 * published by the Free Software Foundation. Oracle designates this 7 * particular file as subject to the "Classpath" exception as provided 8 * by Oracle in the LICENSE file that accompanied this code. 9 * 10 * This code is distributed in the hope that it will be useful, but WITHOUT 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 * version 2 for more details (a copy is included in the LICENSE file that 14 * accompanied this code). 15 * 16 * You should have received a copy of the GNU General Public License version 17 * 2 along with this work; if not, write to the Free Software Foundation, 18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 19 * 20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 21 * or visit www.oracle.com if you need additional information or have any 22 * questions. 23 */ 24 25/* 26 * This file is available under and governed by the GNU General Public 27 * License version 2 only, as published by the Free Software Foundation. 28 * However, the following notice accompanied the original version of this 29 * file and, per its terms, should not be removed: 30 * 31 * Copyright (c) 2004 World Wide Web Consortium, 32 * 33 * (Massachusetts Institute of Technology, European Research Consortium for 34 * Informatics and Mathematics, Keio University). All Rights Reserved. This 35 * work is distributed under the W3C(r) Software License [1] in the hope that 36 * it will be useful, but WITHOUT ANY WARRANTY; without even the implied 37 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 38 * 39 * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 40 */ 41 42package org.w3c.dom; 43 44/** 45 * The <code>Node</code> interface is the primary datatype for the entire 46 * Document Object Model. It represents a single node in the document tree. 47 * While all objects implementing the <code>Node</code> interface expose 48 * methods for dealing with children, not all objects implementing the 49 * <code>Node</code> interface may have children. For example, 50 * <code>Text</code> nodes may not have children, and adding children to 51 * such nodes results in a <code>DOMException</code> being raised. 52 * <p>The attributes <code>nodeName</code>, <code>nodeValue</code> and 53 * <code>attributes</code> are included as a mechanism to get at node 54 * information without casting down to the specific derived interface. In 55 * cases where there is no obvious mapping of these attributes for a 56 * specific <code>nodeType</code> (e.g., <code>nodeValue</code> for an 57 * <code>Element</code> or <code>attributes</code> for a <code>Comment</code> 58 * ), this returns <code>null</code>. Note that the specialized interfaces 59 * may contain additional and more convenient mechanisms to get and set the 60 * relevant information. 61 * <p>The values of <code>nodeName</code>, 62 * <code>nodeValue</code>, and <code>attributes</code> vary according to the 63 * node type as follows: 64 * <table class="striped"> 65 * <caption style="display:none">Interface table</caption> 66 * <thead> 67 * <tr> 68 * <th scope="col">Interface</th> 69 * <th scope="col">nodeName</th> 70 * <th scope="col">nodeValue</th> 71 * <th scope="col">attributes</th> 72 * </tr> 73 * </thead> 74 * <tbody> 75 * <tr> 76 * <th scope="row"> 77 * <code>Attr</code></th> 78 * <td>same as <code>Attr.name</code></td> 79 * <td>same as 80 * <code>Attr.value</code></td> 81 * <td><code>null</code></td> 82 * </tr> 83 * <tr> 84 * <th scope="row"><code>CDATASection</code></th> 85 * <td> 86 * <code>"#cdata-section"</code></td> 87 * <td>same as <code>CharacterData.data</code>, the 88 * content of the CDATA Section</td> 89 * <td><code>null</code></td> 90 * </tr> 91 * <tr> 92 * <th scope="row"><code>Comment</code></th> 93 * <td> 94 * <code>"#comment"</code></td> 95 * <td>same as <code>CharacterData.data</code>, the 96 * content of the comment</td> 97 * <td><code>null</code></td> 98 * </tr> 99 * <tr> 100 * <th scope="row"><code>Document</code></th> 101 * <td> 102 * <code>"#document"</code></td> 103 * <td><code>null</code></td> 104 * <td><code>null</code></td> 105 * </tr> 106 * <tr> 107 * <th scope="row"> 108 * <code>DocumentFragment</code></th> 109 * <td><code>"#document-fragment"</code></td> 110 * <td> 111 * <code>null</code></td> 112 * <td><code>null</code></td> 113 * </tr> 114 * <tr> 115 * <th scope="row"><code>DocumentType</code></th> 116 * <td>same as 117 * <code>DocumentType.name</code></td> 118 * <td><code>null</code></td> 119 * <td><code>null</code></td> 120 * </tr> 121 * <tr> 122 * <th scope="row"> 123 * <code>Element</code></th> 124 * <td>same as <code>Element.tagName</code></td> 125 * <td><code>null</code></td> 126 * <td> 127 * <code>NamedNodeMap</code></td> 128 * </tr> 129 * <tr> 130 * <th scope="row"><code>Entity</code></th> 131 * <td>entity name</td> 132 * <td><code>null</code></td> 133 * <td> 134 * <code>null</code></td> 135 * </tr> 136 * <tr> 137 * <th scope="row"><code>EntityReference</code></th> 138 * <td>name of entity referenced</td> 139 * <td> 140 * <code>null</code></td> 141 * <td><code>null</code></td> 142 * </tr> 143 * <tr> 144 * <th scope="row"><code>Notation</code></th> 145 * <td>notation name</td> 146 * <td> 147 * <code>null</code></td> 148 * <td><code>null</code></td> 149 * </tr> 150 * <tr> 151 * <th scope="row"><code>ProcessingInstruction</code></th> 152 * <td>same 153 * as <code>ProcessingInstruction.target</code></td> 154 * <td>same as 155 * <code>ProcessingInstruction.data</code></td> 156 * <td><code>null</code></td> 157 * </tr> 158 * <tr> 159 * <th scope="row"><code>Text</code></th> 160 * <td> 161 * <code>"#text"</code></td> 162 * <td>same as <code>CharacterData.data</code>, the content 163 * of the text node</td> 164 * <td><code>null</code></td> 165 * </tr> 166 * </tbody> 167 * </table> 168 * <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>. 169 */ 170public interface Node { 171 // NodeType 172 /** 173 * The node is an <code>Element</code>. 174 */ 175 public static final short ELEMENT_NODE = 1; 176 /** 177 * The node is an <code>Attr</code>. 178 */ 179 public static final short ATTRIBUTE_NODE = 2; 180 /** 181 * The node is a <code>Text</code> node. 182 */ 183 public static final short TEXT_NODE = 3; 184 /** 185 * The node is a <code>CDATASection</code>. 186 */ 187 public static final short CDATA_SECTION_NODE = 4; 188 /** 189 * The node is an <code>EntityReference</code>. 190 */ 191 public static final short ENTITY_REFERENCE_NODE = 5; 192 /** 193 * The node is an <code>Entity</code>. 194 */ 195 public static final short ENTITY_NODE = 6; 196 /** 197 * The node is a <code>ProcessingInstruction</code>. 198 */ 199 public static final short PROCESSING_INSTRUCTION_NODE = 7; 200 /** 201 * The node is a <code>Comment</code>. 202 */ 203 public static final short COMMENT_NODE = 8; 204 /** 205 * The node is a <code>Document</code>. 206 */ 207 public static final short DOCUMENT_NODE = 9; 208 /** 209 * The node is a <code>DocumentType</code>. 210 */ 211 public static final short DOCUMENT_TYPE_NODE = 10; 212 /** 213 * The node is a <code>DocumentFragment</code>. 214 */ 215 public static final short DOCUMENT_FRAGMENT_NODE = 11; 216 /** 217 * The node is a <code>Notation</code>. 218 */ 219 public static final short NOTATION_NODE = 12; 220 221 /** 222 * The name of this node, depending on its type; see the table above. 223 */ 224 public String getNodeName(); 225 226 /** 227 * The value of this node, depending on its type; see the table above. 228 * When it is defined to be <code>null</code>, setting it has no effect, 229 * including if the node is read-only. 230 * @exception DOMException 231 * DOMSTRING_SIZE_ERR: Raised when it would return more characters than 232 * fit in a <code>DOMString</code> variable on the implementation 233 * platform. 234 */ 235 public String getNodeValue() 236 throws DOMException; 237 /** 238 * The value of this node, depending on its type; see the table above. 239 * When it is defined to be <code>null</code>, setting it has no effect, 240 * including if the node is read-only. 241 * @exception DOMException 242 * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly and if 243 * it is not defined to be <code>null</code>. 244 */ 245 public void setNodeValue(String nodeValue) 246 throws DOMException; 247 248 /** 249 * A code representing the type of the underlying object, as defined above. 250 */ 251 public short getNodeType(); 252 253 /** 254 * The parent of this node. All nodes, except <code>Attr</code>, 255 * <code>Document</code>, <code>DocumentFragment</code>, 256 * <code>Entity</code>, and <code>Notation</code> may have a parent. 257 * However, if a node has just been created and not yet added to the 258 * tree, or if it has been removed from the tree, this is 259 * <code>null</code>. 260 */ 261 public Node getParentNode(); 262 263 /** 264 * A <code>NodeList</code> that contains all children of this node. If 265 * there are no children, this is a <code>NodeList</code> containing no 266 * nodes. 267 */ 268 public NodeList getChildNodes(); 269 270 /** 271 * The first child of this node. If there is no such node, this returns 272 * <code>null</code>. 273 */ 274 public Node getFirstChild(); 275 276 /** 277 * The last child of this node. If there is no such node, this returns 278 * <code>null</code>. 279 */ 280 public Node getLastChild(); 281 282 /** 283 * The node immediately preceding this node. If there is no such node, 284 * this returns <code>null</code>. 285 */ 286 public Node getPreviousSibling(); 287 288 /** 289 * The node immediately following this node. If there is no such node, 290 * this returns <code>null</code>. 291 */ 292 public Node getNextSibling(); 293 294 /** 295 * A <code>NamedNodeMap</code> containing the attributes of this node (if 296 * it is an <code>Element</code>) or <code>null</code> otherwise. 297 */ 298 public NamedNodeMap getAttributes(); 299 300 /** 301 * The <code>Document</code> object associated with this node. This is 302 * also the <code>Document</code> object used to create new nodes. When 303 * this node is a <code>Document</code> or a <code>DocumentType</code> 304 * which is not used with any <code>Document</code> yet, this is 305 * <code>null</code>. 306 * 307 * @since 1.4, DOM Level 2 308 */ 309 public Document getOwnerDocument(); 310 311 /** 312 * Inserts the node <code>newChild</code> before the existing child node 313 * <code>refChild</code>. If <code>refChild</code> is <code>null</code>, 314 * insert <code>newChild</code> at the end of the list of children. 315 * <br>If <code>newChild</code> is a <code>DocumentFragment</code> object, 316 * all of its children are inserted, in the same order, before 317 * <code>refChild</code>. If the <code>newChild</code> is already in the 318 * tree, it is first removed. 319 * <p ><b>Note:</b> Inserting a node before itself is implementation 320 * dependent. 321 * @param newChild The node to insert. 322 * @param refChild The reference node, i.e., the node before which the 323 * new node must be inserted. 324 * @return The node being inserted. 325 * @exception DOMException 326 * HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not 327 * allow children of the type of the <code>newChild</code> node, or if 328 * the node to insert is one of this node's ancestors or this node 329 * itself, or if this node is of type <code>Document</code> and the 330 * DOM application attempts to insert a second 331 * <code>DocumentType</code> or <code>Element</code> node. 332 * <br>WRONG_DOCUMENT_ERR: Raised if <code>newChild</code> was created 333 * from a different document than the one that created this node. 334 * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly or 335 * if the parent of the node being inserted is readonly. 336 * <br>NOT_FOUND_ERR: Raised if <code>refChild</code> is not a child of 337 * this node. 338 * <br>NOT_SUPPORTED_ERR: if this node is of type <code>Document</code>, 339 * this exception might be raised if the DOM implementation doesn't 340 * support the insertion of a <code>DocumentType</code> or 341 * <code>Element</code> node. 342 * 343 * @since 1.4, DOM Level 3 344 */ 345 public Node insertBefore(Node newChild, 346 Node refChild) 347 throws DOMException; 348 349 /** 350 * Replaces the child node <code>oldChild</code> with <code>newChild</code> 351 * in the list of children, and returns the <code>oldChild</code> node. 352 * <br>If <code>newChild</code> is a <code>DocumentFragment</code> object, 353 * <code>oldChild</code> is replaced by all of the 354 * <code>DocumentFragment</code> children, which are inserted in the 355 * same order. If the <code>newChild</code> is already in the tree, it 356 * is first removed. 357 * <p ><b>Note:</b> Replacing a node with itself is implementation 358 * dependent. 359 * @param newChild The new node to put in the child list. 360 * @param oldChild The node being replaced in the list. 361 * @return The node replaced. 362 * @exception DOMException 363 * HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not 364 * allow children of the type of the <code>newChild</code> node, or if 365 * the node to put in is one of this node's ancestors or this node 366 * itself, or if this node is of type <code>Document</code> and the 367 * result of the replacement operation would add a second 368 * <code>DocumentType</code> or <code>Element</code> on the 369 * <code>Document</code> node. 370 * <br>WRONG_DOCUMENT_ERR: Raised if <code>newChild</code> was created 371 * from a different document than the one that created this node. 372 * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node or the parent of 373 * the new node is readonly. 374 * <br>NOT_FOUND_ERR: Raised if <code>oldChild</code> is not a child of 375 * this node. 376 * <br>NOT_SUPPORTED_ERR: if this node is of type <code>Document</code>, 377 * this exception might be raised if the DOM implementation doesn't 378 * support the replacement of the <code>DocumentType</code> child or 379 * <code>Element</code> child. 380 * 381 * @since 1.4, DOM Level 3 382 */ 383 public Node replaceChild(Node newChild, 384 Node oldChild) 385 throws DOMException; 386 387 /** 388 * Removes the child node indicated by <code>oldChild</code> from the list 389 * of children, and returns it. 390 * @param oldChild The node being removed. 391 * @return The node removed. 392 * @exception DOMException 393 * NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. 394 * <br>NOT_FOUND_ERR: Raised if <code>oldChild</code> is not a child of 395 * this node. 396 * <br>NOT_SUPPORTED_ERR: if this node is of type <code>Document</code>, 397 * this exception might be raised if the DOM implementation doesn't 398 * support the removal of the <code>DocumentType</code> child or the 399 * <code>Element</code> child. 400 * 401 * @since 1.4, DOM Level 3 402 */ 403 public Node removeChild(Node oldChild) 404 throws DOMException; 405 406 /** 407 * Adds the node <code>newChild</code> to the end of the list of children 408 * of this node. If the <code>newChild</code> is already in the tree, it 409 * is first removed. 410 * @param newChild The node to add.If it is a 411 * <code>DocumentFragment</code> object, the entire contents of the 412 * document fragment are moved into the child list of this node 413 * @return The node added. 414 * @exception DOMException 415 * HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not 416 * allow children of the type of the <code>newChild</code> node, or if 417 * the node to append is one of this node's ancestors or this node 418 * itself, or if this node is of type <code>Document</code> and the 419 * DOM application attempts to append a second 420 * <code>DocumentType</code> or <code>Element</code> node. 421 * <br>WRONG_DOCUMENT_ERR: Raised if <code>newChild</code> was created 422 * from a different document than the one that created this node. 423 * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly or 424 * if the previous parent of the node being inserted is readonly. 425 * <br>NOT_SUPPORTED_ERR: if the <code>newChild</code> node is a child 426 * of the <code>Document</code> node, this exception might be raised 427 * if the DOM implementation doesn't support the removal of the 428 * <code>DocumentType</code> child or <code>Element</code> child. 429 * 430 * @since 1.4, DOM Level 3 431 */ 432 public Node appendChild(Node newChild) 433 throws DOMException; 434 435 /** 436 * Returns whether this node has any children. 437 * @return Returns <code>true</code> if this node has any children, 438 * <code>false</code> otherwise. 439 */ 440 public boolean hasChildNodes(); 441 442 /** 443 * Returns a duplicate of this node, i.e., serves as a generic copy 444 * constructor for nodes. The duplicate node has no parent ( 445 * <code>parentNode</code> is <code>null</code>) and no user data. User 446 * data associated to the imported node is not carried over. However, if 447 * any <code>UserDataHandlers</code> has been specified along with the 448 * associated data these handlers will be called with the appropriate 449 * parameters before this method returns. 450 * <br>Cloning an <code>Element</code> copies all attributes and their 451 * values, including those generated by the XML processor to represent 452 * defaulted attributes, but this method does not copy any children it 453 * contains unless it is a deep clone. This includes text contained in 454 * an the <code>Element</code> since the text is contained in a child 455 * <code>Text</code> node. Cloning an <code>Attr</code> directly, as 456 * opposed to be cloned as part of an <code>Element</code> cloning 457 * operation, returns a specified attribute (<code>specified</code> is 458 * <code>true</code>). Cloning an <code>Attr</code> always clones its 459 * children, since they represent its value, no matter whether this is a 460 * deep clone or not. Cloning an <code>EntityReference</code> 461 * automatically constructs its subtree if a corresponding 462 * <code>Entity</code> is available, no matter whether this is a deep 463 * clone or not. Cloning any other type of node simply returns a copy of 464 * this node. 465 * <br>Note that cloning an immutable subtree results in a mutable copy, 466 * but the children of an <code>EntityReference</code> clone are readonly 467 * . In addition, clones of unspecified <code>Attr</code> nodes are 468 * specified. And, cloning <code>Document</code>, 469 * <code>DocumentType</code>, <code>Entity</code>, and 470 * <code>Notation</code> nodes is implementation dependent. 471 * @param deep If <code>true</code>, recursively clone the subtree under 472 * the specified node; if <code>false</code>, clone only the node 473 * itself (and its attributes, if it is an <code>Element</code>). 474 * @return The duplicate node. 475 */ 476 public Node cloneNode(boolean deep); 477 478 /** 479 * Puts all <code>Text</code> nodes in the full depth of the sub-tree 480 * underneath this <code>Node</code>, including attribute nodes, into a 481 * "normal" form where only structure (e.g., elements, comments, 482 * processing instructions, CDATA sections, and entity references) 483 * separates <code>Text</code> nodes, i.e., there are neither adjacent 484 * <code>Text</code> nodes nor empty <code>Text</code> nodes. This can 485 * be used to ensure that the DOM view of a document is the same as if 486 * it were saved and re-loaded, and is useful when operations (such as 487 * XPointer [<a href='http://www.w3.org/TR/2003/REC-xptr-framework-20030325/'>XPointer</a>] 488 * lookups) that depend on a particular document tree structure are to 489 * be used. If the parameter "normalize-characters" of the 490 * <code>DOMConfiguration</code> object attached to the 491 * <code>Node.ownerDocument</code> is <code>true</code>, this method 492 * will also fully normalize the characters of the <code>Text</code> 493 * nodes. 494 * <p ><b>Note:</b> In cases where the document contains 495 * <code>CDATASections</code>, the normalize operation alone may not be 496 * sufficient, since XPointers do not differentiate between 497 * <code>Text</code> nodes and <code>CDATASection</code> nodes. 498 * 499 * @since 1.4, DOM Level 3 500 */ 501 public void normalize(); 502 503 /** 504 * Tests whether the DOM implementation implements a specific feature and 505 * that feature is supported by this node, as specified in . 506 * @param feature The name of the feature to test. 507 * @param version This is the version number of the feature to test. 508 * @return Returns <code>true</code> if the specified feature is 509 * supported on this node, <code>false</code> otherwise. 510 * 511 * @since 1.4, DOM Level 2 512 */ 513 public boolean isSupported(String feature, 514 String version); 515 516 /** 517 * The namespace URI of this node, or <code>null</code> if it is 518 * unspecified (see ). 519 * <br>This is not a computed value that is the result of a namespace 520 * lookup based on an examination of the namespace declarations in 521 * scope. It is merely the namespace URI given at creation time. 522 * <br>For nodes of any type other than <code>ELEMENT_NODE</code> and 523 * <code>ATTRIBUTE_NODE</code> and nodes created with a DOM Level 1 524 * method, such as <code>Document.createElement()</code>, this is always 525 * <code>null</code>. 526 * <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>] 527 * an attribute does not inherit its namespace from the element it is 528 * attached to. If an attribute is not explicitly given a namespace, it 529 * simply has no namespace. 530 * 531 * @since 1.4, DOM Level 2 532 */ 533 public String getNamespaceURI(); 534 535 /** 536 * The namespace prefix of this node, or <code>null</code> if it is 537 * unspecified. When it is defined to be <code>null</code>, setting it 538 * has no effect, including if the node is read-only. 539 * <br>Note that setting this attribute, when permitted, changes the 540 * <code>nodeName</code> attribute, which holds the qualified name, as 541 * well as the <code>tagName</code> and <code>name</code> attributes of 542 * the <code>Element</code> and <code>Attr</code> interfaces, when 543 * applicable. 544 * <br>Setting the prefix to <code>null</code> makes it unspecified, 545 * setting it to an empty string is implementation dependent. 546 * <br>Note also that changing the prefix of an attribute that is known to 547 * have a default value, does not make a new attribute with the default 548 * value and the original prefix appear, since the 549 * <code>namespaceURI</code> and <code>localName</code> do not change. 550 * <br>For nodes of any type other than <code>ELEMENT_NODE</code> and 551 * <code>ATTRIBUTE_NODE</code> and nodes created with a DOM Level 1 552 * method, such as <code>createElement</code> from the 553 * <code>Document</code> interface, this is always <code>null</code>. 554 * 555 * @since 1.4, DOM Level 2 556 */ 557 public String getPrefix(); 558 /** 559 * The namespace prefix of this node, or <code>null</code> if it is 560 * unspecified. When it is defined to be <code>null</code>, setting it 561 * has no effect, including if the node is read-only. 562 * <br>Note that setting this attribute, when permitted, changes the 563 * <code>nodeName</code> attribute, which holds the qualified name, as 564 * well as the <code>tagName</code> and <code>name</code> attributes of 565 * the <code>Element</code> and <code>Attr</code> interfaces, when 566 * applicable. 567 * <br>Setting the prefix to <code>null</code> makes it unspecified, 568 * setting it to an empty string is implementation dependent. 569 * <br>Note also that changing the prefix of an attribute that is known to 570 * have a default value, does not make a new attribute with the default 571 * value and the original prefix appear, since the 572 * <code>namespaceURI</code> and <code>localName</code> do not change. 573 * <br>For nodes of any type other than <code>ELEMENT_NODE</code> and 574 * <code>ATTRIBUTE_NODE</code> and nodes created with a DOM Level 1 575 * method, such as <code>createElement</code> from the 576 * <code>Document</code> interface, this is always <code>null</code>. 577 * @exception DOMException 578 * INVALID_CHARACTER_ERR: Raised if the specified prefix contains an 579 * illegal character according to the XML version in use specified in 580 * the <code>Document.xmlVersion</code> attribute. 581 * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. 582 * <br>NAMESPACE_ERR: Raised if the specified <code>prefix</code> is 583 * malformed per the Namespaces in XML specification, if the 584 * <code>namespaceURI</code> of this node is <code>null</code>, if the 585 * specified prefix is "xml" and the <code>namespaceURI</code> of this 586 * node is different from "<a href='http://www.w3.org/XML/1998/namespace'> 587 * http://www.w3.org/XML/1998/namespace</a>", if this node is an attribute and the specified prefix is "xmlns" and 588 * 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> of 589 * this node is "xmlns" [<a href='http://www.w3.org/TR/1999/REC-xml-names-19990114/'>XML Namespaces</a>] 590 * . 591 * 592 * @since 1.4, DOM Level 2 593 */ 594 public void setPrefix(String prefix) 595 throws DOMException; 596 597 /** 598 * Returns the local part of the qualified name of this node. 599 * <br>For nodes of any type other than <code>ELEMENT_NODE</code> and 600 * <code>ATTRIBUTE_NODE</code> and nodes created with a DOM Level 1 601 * method, such as <code>Document.createElement()</code>, this is always 602 * <code>null</code>. 603 * 604 * @since 1.4, DOM Level 2 605 */ 606 public String getLocalName(); 607 608 /** 609 * Returns whether this node (if it is an element) has any attributes. 610 * @return Returns <code>true</code> if this node has any attributes, 611 * <code>false</code> otherwise. 612 * 613 * @since 1.4, DOM Level 2 614 */ 615 public boolean hasAttributes(); 616 617 /** 618 * The absolute base URI of this node or <code>null</code> if the 619 * implementation wasn't able to obtain an absolute URI. This value is 620 * computed as described in . However, when the <code>Document</code> 621 * supports the feature "HTML" [<a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>DOM Level 2 HTML</a>] 622 * , the base URI is computed using first the value of the href 623 * attribute of the HTML BASE element if any, and the value of the 624 * <code>documentURI</code> attribute from the <code>Document</code> 625 * interface otherwise. 626 * 627 * @since 1.5, DOM Level 3 628 */ 629 public String getBaseURI(); 630 631 // DocumentPosition 632 /** 633 * The two nodes are disconnected. Order between disconnected nodes is 634 * always implementation-specific. 635 */ 636 public static final short DOCUMENT_POSITION_DISCONNECTED = 0x01; 637 /** 638 * The second node precedes the reference node. 639 */ 640 public static final short DOCUMENT_POSITION_PRECEDING = 0x02; 641 /** 642 * The node follows the reference node. 643 */ 644 public static final short DOCUMENT_POSITION_FOLLOWING = 0x04; 645 /** 646 * The node contains the reference node. A node which contains is always 647 * preceding, too. 648 */ 649 public static final short DOCUMENT_POSITION_CONTAINS = 0x08; 650 /** 651 * The node is contained by the reference node. A node which is contained 652 * is always following, too. 653 */ 654 public static final short DOCUMENT_POSITION_CONTAINED_BY = 0x10; 655 /** 656 * The determination of preceding versus following is 657 * implementation-specific. 658 */ 659 public static final short DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20; 660 661 /** 662 * Compares the reference node, i.e. the node on which this method is 663 * being called, with a node, i.e. the one passed as a parameter, with 664 * regard to their position in the document and according to the 665 * document order. 666 * @param other The node to compare against the reference node. 667 * @return Returns how the node is positioned relatively to the reference 668 * node. 669 * @exception DOMException 670 * NOT_SUPPORTED_ERR: when the compared nodes are from different DOM 671 * implementations that do not coordinate to return consistent 672 * implementation-specific results. 673 * 674 * @since 1.5, DOM Level 3 675 */ 676 public short compareDocumentPosition(Node other) 677 throws DOMException; 678 679 /** 680 * This attribute returns the text content of this node and its 681 * descendants. When it is defined to be <code>null</code>, setting it 682 * has no effect. On setting, any possible children this node may have 683 * are removed and, if it the new string is not empty or 684 * <code>null</code>, replaced by a single <code>Text</code> node 685 * containing the string this attribute is set to. 686 * <br> On getting, no serialization is performed, the returned string 687 * does not contain any markup. No whitespace normalization is performed 688 * and the returned string does not contain the white spaces in element 689 * content (see the attribute 690 * <code>Text.isElementContentWhitespace</code>). Similarly, on setting, 691 * no parsing is performed either, the input string is taken as pure 692 * textual content. 693 * <br>The string returned is made of the text content of this node 694 * depending on its type, as defined below: 695 * <table class="striped"> 696 * <caption style="display:none">Node/Content table</caption> 697 * <thead> 698 * <tr> 699 * <th scope="col">Node type</th> 700 * <th scope="col">Content</th> 701 * </tr> 702 * </thead> 703 * <tbody> 704 * <tr> 705 * <th scope="row"> 706 * ELEMENT_NODE, ATTRIBUTE_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, 707 * DOCUMENT_FRAGMENT_NODE</th> 708 * <td>concatenation of the <code>textContent</code> 709 * attribute value of every child node, excluding COMMENT_NODE and 710 * PROCESSING_INSTRUCTION_NODE nodes. This is the empty string if the 711 * node has no children.</td> 712 * </tr> 713 * <tr> 714 * <th scope="row">TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODE, 715 * PROCESSING_INSTRUCTION_NODE</th> 716 * <td><code>nodeValue</code></td> 717 * </tr> 718 * <tr> 719 * <th scope="row">DOCUMENT_NODE, 720 * DOCUMENT_TYPE_NODE, NOTATION_NODE</th> 721 * <td><em>null</em></td> 722 * </tr> 723 * </tbody> 724 * </table> 725 * @exception DOMException 726 * DOMSTRING_SIZE_ERR: Raised when it would return more characters than 727 * fit in a <code>DOMString</code> variable on the implementation 728 * platform. 729 * 730 * @since 1.5, DOM Level 3 731 */ 732 public String getTextContent() 733 throws DOMException; 734 /** 735 * This attribute returns the text content of this node and its 736 * descendants. When it is defined to be <code>null</code>, setting it 737 * has no effect. On setting, any possible children this node may have 738 * are removed and, if it the new string is not empty or 739 * <code>null</code>, replaced by a single <code>Text</code> node 740 * containing the string this attribute is set to. 741 * <br> On getting, no serialization is performed, the returned string 742 * does not contain any markup. No whitespace normalization is performed 743 * and the returned string does not contain the white spaces in element 744 * content (see the attribute 745 * <code>Text.isElementContentWhitespace</code>). Similarly, on setting, 746 * no parsing is performed either, the input string is taken as pure 747 * textual content. 748 * <br>The string returned is made of the text content of this node 749 * depending on its type, as defined below: 750 * <table class="striped"> 751 * <caption style="display:none">Node/Content table</caption> 752 * <thead> 753 * <tr> 754 * <th scope="col">Node type</th> 755 * <th scope="col">Content</th> 756 * </tr> 757 * </thead> 758 * <tbody> 759 * <tr> 760 * <th scope="row"> 761 * ELEMENT_NODE, ATTRIBUTE_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, 762 * DOCUMENT_FRAGMENT_NODE</th> 763 * <td>concatenation of the <code>textContent</code> 764 * attribute value of every child node, excluding COMMENT_NODE and 765 * PROCESSING_INSTRUCTION_NODE nodes. This is the empty string if the 766 * node has no children.</td> 767 * </tr> 768 * <tr> 769 * <th scope="row">TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODE, 770 * PROCESSING_INSTRUCTION_NODE</th> 771 * <td><code>nodeValue</code></td> 772 * </tr> 773 * <tr> 774 * <th scope="row">DOCUMENT_NODE, 775 * DOCUMENT_TYPE_NODE, NOTATION_NODE</th> 776 * <td><em>null</em></td> 777 * </tr> 778 * </tbody> 779 * </table> 780 * @exception DOMException 781 * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly. 782 * 783 * @since 1.5, DOM Level 3 784 */ 785 public void setTextContent(String textContent) 786 throws DOMException; 787 788 /** 789 * Returns whether this node is the same node as the given one. 790 * <br>This method provides a way to determine whether two 791 * <code>Node</code> references returned by the implementation reference 792 * the same object. When two <code>Node</code> references are references 793 * to the same object, even if through a proxy, the references may be 794 * used completely interchangeably, such that all attributes have the 795 * same values and calling the same DOM method on either reference 796 * always has exactly the same effect. 797 * @param other The node to test against. 798 * @return Returns <code>true</code> if the nodes are the same, 799 * <code>false</code> otherwise. 800 * 801 * @since 1.5, DOM Level 3 802 */ 803 public boolean isSameNode(Node other); 804 805 /** 806 * Look up the prefix associated to the given namespace URI, starting from 807 * this node. The default namespace declarations are ignored by this 808 * method. 809 * <br>See for details on the algorithm used by this method. 810 * @param namespaceURI The namespace URI to look for. 811 * @return Returns an associated namespace prefix if found or 812 * <code>null</code> if none is found. If more than one prefix are 813 * associated to the namespace prefix, the returned namespace prefix 814 * is implementation dependent. 815 * 816 * @since 1.5, DOM Level 3 817 */ 818 public String lookupPrefix(String namespaceURI); 819 820 /** 821 * This method checks if the specified <code>namespaceURI</code> is the 822 * default namespace or not. 823 * @param namespaceURI The namespace URI to look for. 824 * @return Returns <code>true</code> if the specified 825 * <code>namespaceURI</code> is the default namespace, 826 * <code>false</code> otherwise. 827 * 828 * @since 1.5, DOM Level 3 829 */ 830 public boolean isDefaultNamespace(String namespaceURI); 831 832 /** 833 * Look up the namespace URI associated to the given prefix, starting from 834 * this node. 835 * <br>See for details on the algorithm used by this method. 836 * @param prefix The prefix to look for. If this parameter is 837 * <code>null</code>, the method will return the default namespace URI 838 * if any. 839 * @return Returns the associated namespace URI or <code>null</code> if 840 * none is found. 841 * 842 * @since 1.5, DOM Level 3 843 */ 844 public String lookupNamespaceURI(String prefix); 845 846 /** 847 * Tests whether two nodes are equal. 848 * <br>This method tests for equality of nodes, not sameness (i.e., 849 * whether the two nodes are references to the same object) which can be 850 * tested with <code>Node.isSameNode()</code>. All nodes that are the 851 * same will also be equal, though the reverse may not be true. 852 * <br>Two nodes are equal if and only if the following conditions are 853 * satisfied: 854 * <ul> 855 * <li>The two nodes are of the same type. 856 * </li> 857 * <li>The following string 858 * attributes are equal: <code>nodeName</code>, <code>localName</code>, 859 * <code>namespaceURI</code>, <code>prefix</code>, <code>nodeValue</code> 860 * . This is: they are both <code>null</code>, or they have the same 861 * length and are character for character identical. 862 * </li> 863 * <li>The 864 * <code>attributes</code> <code>NamedNodeMaps</code> are equal. This 865 * is: they are both <code>null</code>, or they have the same length and 866 * for each node that exists in one map there is a node that exists in 867 * the other map and is equal, although not necessarily at the same 868 * index. 869 * </li> 870 * <li>The <code>childNodes</code> <code>NodeLists</code> are equal. 871 * This is: they are both <code>null</code>, or they have the same 872 * length and contain equal nodes at the same index. Note that 873 * normalization can affect equality; to avoid this, nodes should be 874 * normalized before being compared. 875 * </li> 876 * </ul> 877 * <br>For two <code>DocumentType</code> nodes to be equal, the following 878 * conditions must also be satisfied: 879 * <ul> 880 * <li>The following string attributes 881 * are equal: <code>publicId</code>, <code>systemId</code>, 882 * <code>internalSubset</code>. 883 * </li> 884 * <li>The <code>entities</code> 885 * <code>NamedNodeMaps</code> are equal. 886 * </li> 887 * <li>The <code>notations</code> 888 * <code>NamedNodeMaps</code> are equal. 889 * </li> 890 * </ul> 891 * <br>On the other hand, the following do not affect equality: the 892 * <code>ownerDocument</code>, <code>baseURI</code>, and 893 * <code>parentNode</code> attributes, the <code>specified</code> 894 * attribute for <code>Attr</code> nodes, the <code>schemaTypeInfo</code> 895 * attribute for <code>Attr</code> and <code>Element</code> nodes, the 896 * <code>Text.isElementContentWhitespace</code> attribute for 897 * <code>Text</code> nodes, as well as any user data or event listeners 898 * registered on the nodes. 899 * <p ><b>Note:</b> As a general rule, anything not mentioned in the 900 * description above is not significant in consideration of equality 901 * checking. Note that future versions of this specification may take 902 * into account more attributes and implementations conform to this 903 * specification are expected to be updated accordingly. 904 * @param arg The node to compare equality with. 905 * @return Returns <code>true</code> if the nodes are equal, 906 * <code>false</code> otherwise. 907 * 908 * @since 1.5, DOM Level 3 909 */ 910 public boolean isEqualNode(Node arg); 911 912 /** 913 * This method returns a specialized object which implements the 914 * specialized APIs of the specified feature and version, as specified 915 * in . The specialized object may also be obtained by using 916 * binding-specific casting methods but is not necessarily expected to, 917 * as discussed in . This method also allow the implementation to 918 * provide specialized objects which do not support the <code>Node</code> 919 * interface. 920 * @param feature The name of the feature requested. Note that any plus 921 * sign "+" prepended to the name of the feature will be ignored since 922 * it is not significant in the context of this method. 923 * @param version This is the version number of the feature to test. 924 * @return Returns an object which implements the specialized APIs of 925 * the specified feature and version, if any, or <code>null</code> if 926 * there is no object which implements interfaces associated with that 927 * feature. If the <code>DOMObject</code> returned by this method 928 * implements the <code>Node</code> interface, it must delegate to the 929 * primary core <code>Node</code> and not return results inconsistent 930 * with the primary core <code>Node</code> such as attributes, 931 * childNodes, etc. 932 * 933 * @since 1.5, DOM Level 3 934 */ 935 public Object getFeature(String feature, 936 String version); 937 938 /** 939 * Associate an object to a key on this node. The object can later be 940 * retrieved from this node by calling <code>getUserData</code> with the 941 * same key. 942 * @param key The key to associate the object to. 943 * @param data The object to associate to the given key, or 944 * <code>null</code> to remove any existing association to that key. 945 * @param handler The handler to associate to that key, or 946 * <code>null</code>. 947 * @return Returns the <code>DOMUserData</code> previously associated to 948 * the given key on this node, or <code>null</code> if there was none. 949 * 950 * @since 1.5, DOM Level 3 951 */ 952 public Object setUserData(String key, 953 Object data, 954 UserDataHandler handler); 955 956 /** 957 * Retrieves the object associated to a key on a this node. The object 958 * must first have been set to this node by calling 959 * <code>setUserData</code> with the same key. 960 * @param key The key the object is associated to. 961 * @return Returns the <code>DOMUserData</code> associated to the given 962 * key on this node, or <code>null</code> if there was none. 963 * 964 * @since 1.5, DOM Level 3 965 */ 966 public Object getUserData(String key); 967 968} 969