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