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>Document</code> interface represents the entire HTML or XML
  15. * document. Conceptually, it is the root of the document tree, and provides
  16. * the primary access to the document's data.
  17. * <p>Since elements, text nodes, comments, processing instructions, etc.
  18. * cannot exist outside the context of a <code>Document</code>, the
  19. * <code>Document</code> interface also contains the factory methods needed
  20. * to create these objects. The <code>Node</code> objects created have a
  21. * <code>ownerDocument</code> attribute which associates them with the
  22. * <code>Document</code> within whose context they were created.
  23. * <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>.
  24. */
  25. public interface Document extends Node {
  26. /**
  27. * The Document Type Declaration (see <code>DocumentType</code>)
  28. * associated with this document. For XML documents without a document
  29. * type declaration this returns <code>null</code>. For HTML documents,
  30. * a <code>DocumentType</code> object may be returned, independently of
  31. * the presence or absence of document type declaration in the HTML
  32. * document.
  33. * <br>This provides direct access to the <code>DocumentType</code> node,
  34. * child node of this <code>Document</code>. This node can be set at
  35. * document creation time and later changed through the use of child
  36. * nodes manipulation methods, such as <code>Node.insertBefore</code>,
  37. * or <code>Node.replaceChild</code>. Note, however, that while some
  38. * implementations may instantiate different types of
  39. * <code>Document</code> objects supporting additional features than the
  40. * "Core", such as "HTML" [<a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>DOM Level 2 HTML</a>]
  41. * , based on the <code>DocumentType</code> specified at creation time,
  42. * changing it afterwards is very unlikely to result in a change of the
  43. * features supported.
  44. * @version DOM Level 3
  45. */
  46. public DocumentType getDoctype();
  47. /**
  48. * The <code>DOMImplementation</code> object that handles this document. A
  49. * DOM application may use objects from multiple implementations.
  50. */
  51. public DOMImplementation getImplementation();
  52. /**
  53. * This is a convenience attribute that allows direct access to the child
  54. * node that is the document element of the document.
  55. */
  56. public Element getDocumentElement();
  57. /**
  58. * Creates an element of the type specified. Note that the instance
  59. * returned implements the <code>Element</code> interface, so attributes
  60. * can be specified directly on the returned object.
  61. * <br>In addition, if there are known attributes with default values,
  62. * <code>Attr</code> nodes representing them are automatically created
  63. * and attached to the element.
  64. * <br>To create an element with a qualified name and namespace URI, use
  65. * the <code>createElementNS</code> method.
  66. * @param tagName The name of the element type to instantiate. For XML,
  67. * this is case-sensitive, otherwise it depends on the
  68. * case-sensitivity of the markup language in use. In that case, the
  69. * name is mapped to the canonical form of that markup by the DOM
  70. * implementation.
  71. * @return A new <code>Element</code> object with the
  72. * <code>nodeName</code> attribute set to <code>tagName</code>, and
  73. * <code>localName</code>, <code>prefix</code>, and
  74. * <code>namespaceURI</code> set to <code>null</code>.
  75. * @exception DOMException
  76. * INVALID_CHARACTER_ERR: Raised if the specified name is not an XML
  77. * name according to the XML version in use specified in the
  78. * <code>Document.xmlVersion</code> attribute.
  79. */
  80. public Element createElement(String tagName)
  81. throws DOMException;
  82. /**
  83. * Creates an empty <code>DocumentFragment</code> object.
  84. * @return A new <code>DocumentFragment</code>.
  85. */
  86. public DocumentFragment createDocumentFragment();
  87. /**
  88. * Creates a <code>Text</code> node given the specified string.
  89. * @param data The data for the node.
  90. * @return The new <code>Text</code> object.
  91. */
  92. public Text createTextNode(String data);
  93. /**
  94. * Creates a <code>Comment</code> node given the specified string.
  95. * @param data The data for the node.
  96. * @return The new <code>Comment</code> object.
  97. */
  98. public Comment createComment(String data);
  99. /**
  100. * Creates a <code>CDATASection</code> node whose value is the specified
  101. * string.
  102. * @param data The data for the <code>CDATASection</code> contents.
  103. * @return The new <code>CDATASection</code> object.
  104. * @exception DOMException
  105. * NOT_SUPPORTED_ERR: Raised if this document is an HTML document.
  106. */
  107. public CDATASection createCDATASection(String data)
  108. throws DOMException;
  109. /**
  110. * Creates a <code>ProcessingInstruction</code> node given the specified
  111. * name and data strings.
  112. * @param target The target part of the processing instruction.Unlike
  113. * <code>Document.createElementNS</code> or
  114. * <code>Document.createAttributeNS</code>, no namespace well-formed
  115. * checking is done on the target name. Applications should invoke
  116. * <code>Document.normalizeDocument()</code> with the parameter "
  117. * namespaces" set to <code>true</code> in order to ensure that the
  118. * target name is namespace well-formed.
  119. * @param data The data for the node.
  120. * @return The new <code>ProcessingInstruction</code> object.
  121. * @exception DOMException
  122. * INVALID_CHARACTER_ERR: Raised if the specified target is not an XML
  123. * name according to the XML version in use specified in the
  124. * <code>Document.xmlVersion</code> attribute.
  125. * <br>NOT_SUPPORTED_ERR: Raised if this document is an HTML document.
  126. */
  127. public ProcessingInstruction createProcessingInstruction(String target,
  128. String data)
  129. throws DOMException;
  130. /**
  131. * Creates an <code>Attr</code> of the given name. Note that the
  132. * <code>Attr</code> instance can then be set on an <code>Element</code>
  133. * using the <code>setAttributeNode</code> method.
  134. * <br>To create an attribute with a qualified name and namespace URI, use
  135. * the <code>createAttributeNS</code> method.
  136. * @param name The name of the attribute.
  137. * @return A new <code>Attr</code> object with the <code>nodeName</code>
  138. * attribute set to <code>name</code>, and <code>localName</code>,
  139. * <code>prefix</code>, and <code>namespaceURI</code> set to
  140. * <code>null</code>. The value of the attribute is the empty string.
  141. * @exception DOMException
  142. * INVALID_CHARACTER_ERR: Raised if the specified name is not an XML
  143. * name according to the XML version in use specified in the
  144. * <code>Document.xmlVersion</code> attribute.
  145. */
  146. public Attr createAttribute(String name)
  147. throws DOMException;
  148. /**
  149. * Creates an <code>EntityReference</code> object. In addition, if the
  150. * referenced entity is known, the child list of the
  151. * <code>EntityReference</code> node is made the same as that of the
  152. * corresponding <code>Entity</code> node.
  153. * <p ><b>Note:</b> If any descendant of the <code>Entity</code> node has
  154. * an unbound namespace prefix, the corresponding descendant of the
  155. * created <code>EntityReference</code> node is also unbound; (its
  156. * <code>namespaceURI</code> is <code>null</code>). The DOM Level 2 and
  157. * 3 do not support any mechanism to resolve namespace prefixes in this
  158. * case.
  159. * @param name The name of the entity to reference.Unlike
  160. * <code>Document.createElementNS</code> or
  161. * <code>Document.createAttributeNS</code>, no namespace well-formed
  162. * checking is done on the entity name. Applications should invoke
  163. * <code>Document.normalizeDocument()</code> with the parameter "
  164. * namespaces" set to <code>true</code> in order to ensure that the
  165. * entity name is namespace well-formed.
  166. * @return The new <code>EntityReference</code> object.
  167. * @exception DOMException
  168. * INVALID_CHARACTER_ERR: Raised if the specified name is not an XML
  169. * name according to the XML version in use specified in the
  170. * <code>Document.xmlVersion</code> attribute.
  171. * <br>NOT_SUPPORTED_ERR: Raised if this document is an HTML document.
  172. */
  173. public EntityReference createEntityReference(String name)
  174. throws DOMException;
  175. /**
  176. * Returns a <code>NodeList</code> of all the <code>Elements</code> in
  177. * document order with a given tag name and are contained in the
  178. * document.
  179. * @param tagname The name of the tag to match on. The special value "*"
  180. * matches all tags. For XML, the <code>tagname</code> parameter is
  181. * case-sensitive, otherwise it depends on the case-sensitivity of the
  182. * markup language in use.
  183. * @return A new <code>NodeList</code> object containing all the matched
  184. * <code>Elements</code>.
  185. */
  186. public NodeList getElementsByTagName(String tagname);
  187. /**
  188. * Imports a node from another document to this document, without altering
  189. * or removing the source node from the original document; this method
  190. * creates a new copy of the source node. The returned node has no
  191. * parent; (<code>parentNode</code> is <code>null</code>).
  192. * <br>For all nodes, importing a node creates a node object owned by the
  193. * importing document, with attribute values identical to the source
  194. * node's <code>nodeName</code> and <code>nodeType</code>, plus the
  195. * attributes related to namespaces (<code>prefix</code>,
  196. * <code>localName</code>, and <code>namespaceURI</code>). As in the
  197. * <code>cloneNode</code> operation, the source node is not altered.
  198. * User data associated to the imported node is not carried over.
  199. * However, if any <code>UserDataHandlers</code> has been specified
  200. * along with the associated data these handlers will be called with the
  201. * appropriate parameters before this method returns.
  202. * <br>Additional information is copied as appropriate to the
  203. * <code>nodeType</code>, attempting to mirror the behavior expected if
  204. * a fragment of XML or HTML source was copied from one document to
  205. * another, recognizing that the two documents may have different DTDs
  206. * in the XML case. The following list describes the specifics for each
  207. * type of node.
  208. * <dl>
  209. * <dt>ATTRIBUTE_NODE</dt>
  210. * <dd>The <code>ownerElement</code> attribute
  211. * is set to <code>null</code> and the <code>specified</code> flag is
  212. * set to <code>true</code> on the generated <code>Attr</code>. The
  213. * descendants of the source <code>Attr</code> are recursively imported
  214. * and the resulting nodes reassembled to form the corresponding subtree.
  215. * Note that the <code>deep</code> parameter has no effect on
  216. * <code>Attr</code> nodes; they always carry their children with them
  217. * when imported.</dd>
  218. * <dt>DOCUMENT_FRAGMENT_NODE</dt>
  219. * <dd>If the <code>deep</code> option
  220. * was set to <code>true</code>, the descendants of the source
  221. * <code>DocumentFragment</code> are recursively imported and the
  222. * resulting nodes reassembled under the imported
  223. * <code>DocumentFragment</code> to form the corresponding subtree.
  224. * Otherwise, this simply generates an empty
  225. * <code>DocumentFragment</code>.</dd>
  226. * <dt>DOCUMENT_NODE</dt>
  227. * <dd><code>Document</code>
  228. * nodes cannot be imported.</dd>
  229. * <dt>DOCUMENT_TYPE_NODE</dt>
  230. * <dd><code>DocumentType</code>
  231. * nodes cannot be imported.</dd>
  232. * <dt>ELEMENT_NODE</dt>
  233. * <dd><em>Specified</em> attribute nodes of the source element are imported, and the generated
  234. * <code>Attr</code> nodes are attached to the generated
  235. * <code>Element</code>. Default attributes are <em>not</em> copied, though if the document being imported into defines default
  236. * attributes for this element name, those are assigned. If the
  237. * <code>importNode</code> <code>deep</code> parameter was set to
  238. * <code>true</code>, the descendants of the source element are
  239. * recursively imported and the resulting nodes reassembled to form the
  240. * corresponding subtree.</dd>
  241. * <dt>ENTITY_NODE</dt>
  242. * <dd><code>Entity</code> nodes can be
  243. * imported, however in the current release of the DOM the
  244. * <code>DocumentType</code> is readonly. Ability to add these imported
  245. * nodes to a <code>DocumentType</code> will be considered for addition
  246. * to a future release of the DOM.On import, the <code>publicId</code>,
  247. * <code>systemId</code>, and <code>notationName</code> attributes are
  248. * copied. If a <code>deep</code> import is requested, the descendants
  249. * of the the source <code>Entity</code> are recursively imported and
  250. * the resulting nodes reassembled to form the corresponding subtree.</dd>
  251. * <dt>
  252. * ENTITY_REFERENCE_NODE</dt>
  253. * <dd>Only the <code>EntityReference</code> itself is
  254. * copied, even if a <code>deep</code> import is requested, since the
  255. * source and destination documents might have defined the entity
  256. * differently. If the document being imported into provides a
  257. * definition for this entity name, its value is assigned.</dd>
  258. * <dt>NOTATION_NODE</dt>
  259. * <dd>
  260. * <code>Notation</code> nodes can be imported, however in the current
  261. * release of the DOM the <code>DocumentType</code> is readonly. Ability
  262. * to add these imported nodes to a <code>DocumentType</code> will be
  263. * considered for addition to a future release of the DOM.On import, the
  264. * <code>publicId</code> and <code>systemId</code> attributes are copied.
  265. * Note that the <code>deep</code> parameter has no effect on this type
  266. * of nodes since they cannot have any children.</dd>
  267. * <dt>
  268. * PROCESSING_INSTRUCTION_NODE</dt>
  269. * <dd>The imported node copies its
  270. * <code>target</code> and <code>data</code> values from those of the
  271. * source node.Note that the <code>deep</code> parameter has no effect
  272. * on this type of nodes since they cannot have any children.</dd>
  273. * <dt>TEXT_NODE,
  274. * CDATA_SECTION_NODE, COMMENT_NODE</dt>
  275. * <dd>These three types of nodes inheriting
  276. * from <code>CharacterData</code> copy their <code>data</code> and
  277. * <code>length</code> attributes from those of the source node.Note
  278. * that the <code>deep</code> parameter has no effect on these types of
  279. * nodes since they cannot have any children.</dd>
  280. * </dl>
  281. * @param importedNode The node to import.
  282. * @param deep If <code>true</code>, recursively import the subtree under
  283. * the specified node; if <code>false</code>, import only the node
  284. * itself, as explained above. This has no effect on nodes that cannot
  285. * have any children, and on <code>Attr</code>, and
  286. * <code>EntityReference</code> nodes.
  287. * @return The imported node that belongs to this <code>Document</code>.
  288. * @exception DOMException
  289. * NOT_SUPPORTED_ERR: Raised if the type of node being imported is not
  290. * supported.
  291. * <br>INVALID_CHARACTER_ERR: Raised if one of the imported names is not
  292. * an XML name according to the XML version in use specified in the
  293. * <code>Document.xmlVersion</code> attribute. This may happen when
  294. * importing an XML 1.1 [<a href='http://www.w3.org/TR/2004/REC-xml11-20040204/'>XML 1.1</a>] element
  295. * into an XML 1.0 document, for instance.
  296. * @since DOM Level 2
  297. */
  298. public Node importNode(Node importedNode,
  299. boolean deep)
  300. throws DOMException;
  301. /**
  302. * Creates an element of the given qualified name and namespace URI.
  303. * <br>Per [<a href='http://www.w3.org/TR/1999/REC-xml-names-19990114/'>XML Namespaces</a>]
  304. * , applications must use the value <code>null</code> as the
  305. * namespaceURI parameter for methods if they wish to have no namespace.
  306. * @param namespaceURI The namespace URI of the element to create.
  307. * @param qualifiedName The qualified name of the element type to
  308. * instantiate.
  309. * @return A new <code>Element</code> object with the following
  310. * attributes:
  311. * <table border='1' cellpadding='3'>
  312. * <tr>
  313. * <th>Attribute</th>
  314. * <th>Value</th>
  315. * </tr>
  316. * <tr>
  317. * <td valign='top' rowspan='1' colspan='1'><code>Node.nodeName</code></td>
  318. * <td valign='top' rowspan='1' colspan='1'>
  319. * <code>qualifiedName</code></td>
  320. * </tr>
  321. * <tr>
  322. * <td valign='top' rowspan='1' colspan='1'><code>Node.namespaceURI</code></td>
  323. * <td valign='top' rowspan='1' colspan='1'>
  324. * <code>namespaceURI</code></td>
  325. * </tr>
  326. * <tr>
  327. * <td valign='top' rowspan='1' colspan='1'><code>Node.prefix</code></td>
  328. * <td valign='top' rowspan='1' colspan='1'>prefix, extracted
  329. * from <code>qualifiedName</code>, or <code>null</code> if there is
  330. * no prefix</td>
  331. * </tr>
  332. * <tr>
  333. * <td valign='top' rowspan='1' colspan='1'><code>Node.localName</code></td>
  334. * <td valign='top' rowspan='1' colspan='1'>local name, extracted from
  335. * <code>qualifiedName</code></td>
  336. * </tr>
  337. * <tr>
  338. * <td valign='top' rowspan='1' colspan='1'><code>Element.tagName</code></td>
  339. * <td valign='top' rowspan='1' colspan='1'>
  340. * <code>qualifiedName</code></td>
  341. * </tr>
  342. * </table>
  343. * @exception DOMException
  344. * INVALID_CHARACTER_ERR: Raised if the specified
  345. * <code>qualifiedName</code> is not an XML name according to the XML
  346. * version in use specified in the <code>Document.xmlVersion</code>
  347. * attribute.
  348. * <br>NAMESPACE_ERR: Raised if the <code>qualifiedName</code> is a
  349. * malformed qualified name, if the <code>qualifiedName</code> has a
  350. * prefix and the <code>namespaceURI</code> is <code>null</code>, or
  351. * if the <code>qualifiedName</code> has a prefix that is "xml" and
  352. * the <code>namespaceURI</code> is different from "<a href='http://www.w3.org/XML/1998/namespace'>
  353. * http://www.w3.org/XML/1998/namespace</a>" [<a href='http://www.w3.org/TR/1999/REC-xml-names-19990114/'>XML Namespaces</a>]
  354. * , or if the <code>qualifiedName</code> or its prefix is "xmlns" and
  355. * the <code>namespaceURI</code> is different from "<a href='http://www.w3.org/2000/xmlns/'>http://www.w3.org/2000/xmlns/</a>", or if the <code>namespaceURI</code> is "<a href='http://www.w3.org/2000/xmlns/'>http://www.w3.org/2000/xmlns/</a>" and neither the <code>qualifiedName</code> nor its prefix is "xmlns".
  356. * <br>NOT_SUPPORTED_ERR: Always thrown if the current document does not
  357. * support the <code>"XML"</code> feature, since namespaces were
  358. * defined by XML.
  359. * @since DOM Level 2
  360. */
  361. public Element createElementNS(String namespaceURI,
  362. String qualifiedName)
  363. throws DOMException;
  364. /**
  365. * Creates an attribute of the given qualified name and namespace URI.
  366. * <br>Per [<a href='http://www.w3.org/TR/1999/REC-xml-names-19990114/'>XML Namespaces</a>]
  367. * , applications must use the value <code>null</code> as the
  368. * <code>namespaceURI</code> parameter for methods if they wish to have
  369. * no namespace.
  370. * @param namespaceURI The namespace URI of the attribute to create.
  371. * @param qualifiedName The qualified name of the attribute to
  372. * instantiate.
  373. * @return A new <code>Attr</code> object with the following attributes:
  374. * <table border='1' cellpadding='3'>
  375. * <tr>
  376. * <th>
  377. * Attribute</th>
  378. * <th>Value</th>
  379. * </tr>
  380. * <tr>
  381. * <td valign='top' rowspan='1' colspan='1'><code>Node.nodeName</code></td>
  382. * <td valign='top' rowspan='1' colspan='1'>qualifiedName</td>
  383. * </tr>
  384. * <tr>
  385. * <td valign='top' rowspan='1' colspan='1'>
  386. * <code>Node.namespaceURI</code></td>
  387. * <td valign='top' rowspan='1' colspan='1'><code>namespaceURI</code></td>
  388. * </tr>
  389. * <tr>
  390. * <td valign='top' rowspan='1' colspan='1'>
  391. * <code>Node.prefix</code></td>
  392. * <td valign='top' rowspan='1' colspan='1'>prefix, extracted from
  393. * <code>qualifiedName</code>, or <code>null</code> if there is no
  394. * prefix</td>
  395. * </tr>
  396. * <tr>
  397. * <td valign='top' rowspan='1' colspan='1'><code>Node.localName</code></td>
  398. * <td valign='top' rowspan='1' colspan='1'>local name, extracted from
  399. * <code>qualifiedName</code></td>
  400. * </tr>
  401. * <tr>
  402. * <td valign='top' rowspan='1' colspan='1'><code>Attr.name</code></td>
  403. * <td valign='top' rowspan='1' colspan='1'>
  404. * <code>qualifiedName</code></td>
  405. * </tr>
  406. * <tr>
  407. * <td valign='top' rowspan='1' colspan='1'><code>Node.nodeValue</code></td>
  408. * <td valign='top' rowspan='1' colspan='1'>the empty
  409. * string</td>
  410. * </tr>
  411. * </table>
  412. * @exception DOMException
  413. * INVALID_CHARACTER_ERR: Raised if the specified
  414. * <code>qualifiedName</code> is not an XML name according to the XML
  415. * version in use specified in the <code>Document.xmlVersion</code>
  416. * attribute.
  417. * <br>NAMESPACE_ERR: Raised if the <code>qualifiedName</code> is a
  418. * malformed qualified name, if the <code>qualifiedName</code> has a
  419. * prefix and the <code>namespaceURI</code> is <code>null</code>, if
  420. * the <code>qualifiedName</code> has a prefix that is "xml" and the
  421. * <code>namespaceURI</code> is different from "<a href='http://www.w3.org/XML/1998/namespace'>
  422. * http://www.w3.org/XML/1998/namespace</a>", if the <code>qualifiedName</code> or its prefix is "xmlns" and the
  423. * <code>namespaceURI</code> is different from "<a href='http://www.w3.org/2000/xmlns/'>http://www.w3.org/2000/xmlns/</a>", or if the <code>namespaceURI</code> is "<a href='http://www.w3.org/2000/xmlns/'>http://www.w3.org/2000/xmlns/</a>" and neither the <code>qualifiedName</code> nor its prefix is "xmlns".
  424. * <br>NOT_SUPPORTED_ERR: Always thrown if the current document does not
  425. * support the <code>"XML"</code> feature, since namespaces were
  426. * defined by XML.
  427. * @since DOM Level 2
  428. */
  429. public Attr createAttributeNS(String namespaceURI,
  430. String qualifiedName)
  431. throws DOMException;
  432. /**
  433. * Returns a <code>NodeList</code> of all the <code>Elements</code> with a
  434. * given local name and namespace URI in document order.
  435. * @param namespaceURI The namespace URI of the elements to match on. The
  436. * special value <code>"*"</code> matches all namespaces.
  437. * @param localName The local name of the elements to match on. The
  438. * special value "*" matches all local names.
  439. * @return A new <code>NodeList</code> object containing all the matched
  440. * <code>Elements</code>.
  441. * @since DOM Level 2
  442. */
  443. public NodeList getElementsByTagNameNS(String namespaceURI,
  444. String localName);
  445. /**
  446. * Returns the <code>Element</code> that has an ID attribute with the
  447. * given value. If no such element exists, this returns <code>null</code>
  448. * . If more than one element has an ID attribute with that value, what
  449. * is returned is undefined.
  450. * <br> The DOM implementation is expected to use the attribute
  451. * <code>Attr.isId</code> to determine if an attribute is of type ID.
  452. * <p ><b>Note:</b> Attributes with the name "ID" or "id" are not of type
  453. * ID unless so defined.
  454. * @param elementId The unique <code>id</code> value for an element.
  455. * @return The matching element or <code>null</code> if there is none.
  456. * @since DOM Level 2
  457. */
  458. public Element getElementById(String elementId);
  459. /**
  460. * An attribute specifying the encoding used for this document at the time
  461. * of the parsing. This is <code>null</code> when it is not known, such
  462. * as when the <code>Document</code> was created in memory.
  463. * @since DOM Level 3
  464. */
  465. public String getInputEncoding();
  466. /**
  467. * An attribute specifying, as part of the <a href='http://www.w3.org/TR/2004/REC-xml-20040204#NT-XMLDecl'>XML declaration</a>, the encoding of this document. This is <code>null</code> when
  468. * unspecified or when it is not known, such as when the
  469. * <code>Document</code> was created in memory.
  470. * @since DOM Level 3
  471. */
  472. public String getXmlEncoding();
  473. /**
  474. * An attribute specifying, as part of the <a href='http://www.w3.org/TR/2004/REC-xml-20040204#NT-XMLDecl'>XML declaration</a>, whether this document is standalone. This is <code>false</code> when
  475. * unspecified.
  476. * <p ><b>Note:</b> No verification is done on the value when setting
  477. * this attribute. Applications should use
  478. * <code>Document.normalizeDocument()</code> with the "validate"
  479. * parameter to verify if the value matches the <a href='http://www.w3.org/TR/2004/REC-xml-20040204#sec-rmd'>validity
  480. * constraint for standalone document declaration</a> as defined in [<a href='http://www.w3.org/TR/2004/REC-xml-20040204'>XML 1.0</a>].
  481. * @since DOM Level 3
  482. */
  483. public boolean getXmlStandalone();
  484. /**
  485. * An attribute specifying, as part of the <a href='http://www.w3.org/TR/2004/REC-xml-20040204#NT-XMLDecl'>XML declaration</a>, whether this document is standalone. This is <code>false</code> when
  486. * unspecified.
  487. * <p ><b>Note:</b> No verification is done on the value when setting
  488. * this attribute. Applications should use
  489. * <code>Document.normalizeDocument()</code> with the "validate"
  490. * parameter to verify if the value matches the <a href='http://www.w3.org/TR/2004/REC-xml-20040204#sec-rmd'>validity
  491. * constraint for standalone document declaration</a> as defined in [<a href='http://www.w3.org/TR/2004/REC-xml-20040204'>XML 1.0</a>].
  492. * @exception DOMException
  493. * NOT_SUPPORTED_ERR: Raised if this document does not support the
  494. * "XML" feature.
  495. * @since DOM Level 3
  496. */
  497. public void setXmlStandalone(boolean xmlStandalone)
  498. throws DOMException;
  499. /**
  500. * An attribute specifying, as part of the <a href='http://www.w3.org/TR/2004/REC-xml-20040204#NT-XMLDecl'>XML declaration</a>, the version number of this document. If there is no declaration and if
  501. * this document supports the "XML" feature, the value is
  502. * <code>"1.0"</code>. If this document does not support the "XML"
  503. * feature, the value is always <code>null</code>. Changing this
  504. * attribute will affect methods that check for invalid characters in
  505. * XML names. Application should invoke
  506. * <code>Document.normalizeDocument()</code> in order to check for
  507. * invalid characters in the <code>Node</code>s that are already part of
  508. * this <code>Document</code>.
  509. * <br> DOM applications may use the
  510. * <code>DOMImplementation.hasFeature(feature, version)</code> method
  511. * with parameter values "XMLVersion" and "1.0" (respectively) to
  512. * determine if an implementation supports [<a href='http://www.w3.org/TR/2004/REC-xml-20040204'>XML 1.0</a>]. DOM
  513. * applications may use the same method with parameter values
  514. * "XMLVersion" and "1.1" (respectively) to determine if an
  515. * implementation supports [<a href='http://www.w3.org/TR/2004/REC-xml11-20040204/'>XML 1.1</a>]. In both
  516. * cases, in order to support XML, an implementation must also support
  517. * the "XML" feature defined in this specification. <code>Document</code>
  518. * objects supporting a version of the "XMLVersion" feature must not
  519. * raise a <code>NOT_SUPPORTED_ERR</code> exception for the same version
  520. * number when using <code>Document.xmlVersion</code>.
  521. * @since DOM Level 3
  522. */
  523. public String getXmlVersion();
  524. /**
  525. * An attribute specifying, as part of the <a href='http://www.w3.org/TR/2004/REC-xml-20040204#NT-XMLDecl'>XML declaration</a>, the version number of this document. If there is no declaration and if
  526. * this document supports the "XML" feature, the value is
  527. * <code>"1.0"</code>. If this document does not support the "XML"
  528. * feature, the value is always <code>null</code>. Changing this
  529. * attribute will affect methods that check for invalid characters in
  530. * XML names. Application should invoke
  531. * <code>Document.normalizeDocument()</code> in order to check for
  532. * invalid characters in the <code>Node</code>s that are already part of
  533. * this <code>Document</code>.
  534. * <br> DOM applications may use the
  535. * <code>DOMImplementation.hasFeature(feature, version)</code> method
  536. * with parameter values "XMLVersion" and "1.0" (respectively) to
  537. * determine if an implementation supports [<a href='http://www.w3.org/TR/2004/REC-xml-20040204'>XML 1.0</a>]. DOM
  538. * applications may use the same method with parameter values
  539. * "XMLVersion" and "1.1" (respectively) to determine if an
  540. * implementation supports [<a href='http://www.w3.org/TR/2004/REC-xml11-20040204/'>XML 1.1</a>]. In both
  541. * cases, in order to support XML, an implementation must also support
  542. * the "XML" feature defined in this specification. <code>Document</code>
  543. * objects supporting a version of the "XMLVersion" feature must not
  544. * raise a <code>NOT_SUPPORTED_ERR</code> exception for the same version
  545. * number when using <code>Document.xmlVersion</code>.
  546. * @exception DOMException
  547. * NOT_SUPPORTED_ERR: Raised if the version is set to a value that is
  548. * not supported by this <code>Document</code> or if this document
  549. * does not support the "XML" feature.
  550. * @since DOM Level 3
  551. */
  552. public void setXmlVersion(String xmlVersion)
  553. throws DOMException;
  554. /**
  555. * An attribute specifying whether error checking is enforced or not. When
  556. * set to <code>false</code>, the implementation is free to not test
  557. * every possible error case normally defined on DOM operations, and not
  558. * raise any <code>DOMException</code> on DOM operations or report
  559. * errors while using <code>Document.normalizeDocument()</code>. In case
  560. * of error, the behavior is undefined. This attribute is
  561. * <code>true</code> by default.
  562. * @since DOM Level 3
  563. */
  564. public boolean getStrictErrorChecking();
  565. /**
  566. * An attribute specifying whether error checking is enforced or not. When
  567. * set to <code>false</code>, the implementation is free to not test
  568. * every possible error case normally defined on DOM operations, and not
  569. * raise any <code>DOMException</code> on DOM operations or report
  570. * errors while using <code>Document.normalizeDocument()</code>. In case
  571. * of error, the behavior is undefined. This attribute is
  572. * <code>true</code> by default.
  573. * @since DOM Level 3
  574. */
  575. public void setStrictErrorChecking(boolean strictErrorChecking);
  576. /**
  577. * The location of the document or <code>null</code> if undefined or if
  578. * the <code>Document</code> was created using
  579. * <code>DOMImplementation.createDocument</code>. No lexical checking is
  580. * performed when setting this attribute; this could result in a
  581. * <code>null</code> value returned when using <code>Node.baseURI</code>
  582. * .
  583. * <br> Beware that when the <code>Document</code> supports the feature
  584. * "HTML" [<a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>DOM Level 2 HTML</a>]
  585. * , the href attribute of the HTML BASE element takes precedence over
  586. * this attribute when computing <code>Node.baseURI</code>.
  587. * @since DOM Level 3
  588. */
  589. public String getDocumentURI();
  590. /**
  591. * The location of the document or <code>null</code> if undefined or if
  592. * the <code>Document</code> was created using
  593. * <code>DOMImplementation.createDocument</code>. No lexical checking is
  594. * performed when setting this attribute; this could result in a
  595. * <code>null</code> value returned when using <code>Node.baseURI</code>
  596. * .
  597. * <br> Beware that when the <code>Document</code> supports the feature
  598. * "HTML" [<a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>DOM Level 2 HTML</a>]
  599. * , the href attribute of the HTML BASE element takes precedence over
  600. * this attribute when computing <code>Node.baseURI</code>.
  601. * @since DOM Level 3
  602. */
  603. public void setDocumentURI(String documentURI);
  604. /**
  605. * Attempts to adopt a node from another document to this document. If
  606. * supported, it changes the <code>ownerDocument</code> of the source
  607. * node, its children, as well as the attached attribute nodes if there
  608. * are any. If the source node has a parent it is first removed from the
  609. * child list of its parent. This effectively allows moving a subtree
  610. * from one document to another (unlike <code>importNode()</code> which
  611. * create a copy of the source node instead of moving it). When it
  612. * fails, applications should use <code>Document.importNode()</code>
  613. * instead. Note that if the adopted node is already part of this
  614. * document (i.e. the source and target document are the same), this
  615. * method still has the effect of removing the source node from the
  616. * child list of its parent, if any. The following list describes the
  617. * specifics for each type of node.
  618. * <dl>
  619. * <dt>ATTRIBUTE_NODE</dt>
  620. * <dd>The
  621. * <code>ownerElement</code> attribute is set to <code>null</code> and
  622. * the <code>specified</code> flag is set to <code>true</code> on the
  623. * adopted <code>Attr</code>. The descendants of the source
  624. * <code>Attr</code> are recursively adopted.</dd>
  625. * <dt>DOCUMENT_FRAGMENT_NODE</dt>
  626. * <dd>The
  627. * descendants of the source node are recursively adopted.</dd>
  628. * <dt>DOCUMENT_NODE</dt>
  629. * <dd>
  630. * <code>Document</code> nodes cannot be adopted.</dd>
  631. * <dt>DOCUMENT_TYPE_NODE</dt>
  632. * <dd>
  633. * <code>DocumentType</code> nodes cannot be adopted.</dd>
  634. * <dt>ELEMENT_NODE</dt>
  635. * <dd><em>Specified</em> attribute nodes of the source element are adopted. Default attributes
  636. * are discarded, though if the document being adopted into defines
  637. * default attributes for this element name, those are assigned. The
  638. * descendants of the source element are recursively adopted.</dd>
  639. * <dt>ENTITY_NODE</dt>
  640. * <dd>
  641. * <code>Entity</code> nodes cannot be adopted.</dd>
  642. * <dt>ENTITY_REFERENCE_NODE</dt>
  643. * <dd>Only
  644. * the <code>EntityReference</code> node itself is adopted, the
  645. * descendants are discarded, since the source and destination documents
  646. * might have defined the entity differently. If the document being
  647. * imported into provides a definition for this entity name, its value
  648. * is assigned.</dd>
  649. * <dt>NOTATION_NODE</dt>
  650. * <dd><code>Notation</code> nodes cannot be
  651. * adopted.</dd>
  652. * <dt>PROCESSING_INSTRUCTION_NODE, TEXT_NODE, CDATA_SECTION_NODE,
  653. * COMMENT_NODE</dt>
  654. * <dd>These nodes can all be adopted. No specifics.</dd>
  655. * </dl>
  656. * <p ><b>Note:</b> Since it does not create new nodes unlike the
  657. * <code>Document.importNode()</code> method, this method does not raise
  658. * an <code>INVALID_CHARACTER_ERR</code> exception, and applications
  659. * should use the <code>Document.normalizeDocument()</code> method to
  660. * check if an imported name is not an XML name according to the XML
  661. * version in use.
  662. * @param source The node to move into this document.
  663. * @return The adopted node, or <code>null</code> if this operation
  664. * fails, such as when the source node comes from a different
  665. * implementation.
  666. * @exception DOMException
  667. * NOT_SUPPORTED_ERR: Raised if the source node is of type
  668. * <code>DOCUMENT</code>, <code>DOCUMENT_TYPE</code>.
  669. * <br>NO_MODIFICATION_ALLOWED_ERR: Raised when the source node is
  670. * readonly.
  671. * @since DOM Level 3
  672. */
  673. public Node adoptNode(Node source)
  674. throws DOMException;
  675. /**
  676. * The configuration used when <code>Document.normalizeDocument()</code>
  677. * is invoked.
  678. * @since DOM Level 3
  679. */
  680. public DOMConfiguration getDomConfig();
  681. /**
  682. * This method acts as if the document was going through a save and load
  683. * cycle, putting the document in a "normal" form. As a consequence,
  684. * this method updates the replacement tree of
  685. * <code>EntityReference</code> nodes and normalizes <code>Text</code>
  686. * nodes, as defined in the method <code>Node.normalize()</code>.
  687. * <br> Otherwise, the actual result depends on the features being set on
  688. * the <code>Document.domConfig</code> object and governing what
  689. * operations actually take place. Noticeably this method could also
  690. * make the document namespace well-formed according to the algorithm
  691. * described in , check the character normalization, remove the
  692. * <code>CDATASection</code> nodes, etc. See
  693. * <code>DOMConfiguration</code> for details.
  694. * <pre>// Keep in the document
  695. * the information defined // in the XML Information Set (Java example)
  696. * DOMConfiguration docConfig = myDocument.getDomConfig();
  697. * docConfig.setParameter("infoset", Boolean.TRUE);
  698. * myDocument.normalizeDocument();</pre>
  699. *
  700. * <br>Mutation events, when supported, are generated to reflect the
  701. * changes occurring on the document.
  702. * <br> If errors occur during the invocation of this method, such as an
  703. * attempt to update a read-only node or a <code>Node.nodeName</code>
  704. * contains an invalid character according to the XML version in use,
  705. * errors or warnings (<code>DOMError.SEVERITY_ERROR</code> or
  706. * <code>DOMError.SEVERITY_WARNING</code>) will be reported using the
  707. * <code>DOMErrorHandler</code> object associated with the "error-handler
  708. * " parameter. Note this method might also report fatal errors (
  709. * <code>DOMError.SEVERITY_FATAL_ERROR</code>) if an implementation
  710. * cannot recover from an error.
  711. * @since DOM Level 3
  712. */
  713. public void normalizeDocument();
  714. /**
  715. * Rename an existing node of type <code>ELEMENT_NODE</code> or
  716. * <code>ATTRIBUTE_NODE</code>.
  717. * <br>When possible this simply changes the name of the given node,
  718. * otherwise this creates a new node with the specified name and
  719. * replaces the existing node with the new node as described below.
  720. * <br>If simply changing the name of the given node is not possible, the
  721. * following operations are performed: a new node is created, any
  722. * registered event listener is registered on the new node, any user
  723. * data attached to the old node is removed from that node, the old node
  724. * is removed from its parent if it has one, the children are moved to
  725. * the new node, if the renamed node is an <code>Element</code> its
  726. * attributes are moved to the new node, the new node is inserted at the
  727. * position the old node used to have in its parent's child nodes list
  728. * if it has one, the user data that was attached to the old node is
  729. * attached to the new node.
  730. * <br>When the node being renamed is an <code>Element</code> only the
  731. * specified attributes are moved, default attributes originated from
  732. * the DTD are updated according to the new element name. In addition,
  733. * the implementation may update default attributes from other schemas.
  734. * Applications should use <code>Document.normalizeDocument()</code> to
  735. * guarantee these attributes are up-to-date.
  736. * <br>When the node being renamed is an <code>Attr</code> that is
  737. * attached to an <code>Element</code>, the node is first removed from
  738. * the <code>Element</code> attributes map. Then, once renamed, either
  739. * by modifying the existing node or creating a new one as described
  740. * above, it is put back.
  741. * <br>In addition,
  742. * <ul>
  743. * <li> a user data event <code>NODE_RENAMED</code> is fired,
  744. * </li>
  745. * <li>
  746. * when the implementation supports the feature "MutationNameEvents",
  747. * each mutation operation involved in this method fires the appropriate
  748. * event, and in the end the event {
  749. * <code>http://www.w3.org/2001/xml-events</code>,
  750. * <code>DOMElementNameChanged</code>} or {
  751. * <code>http://www.w3.org/2001/xml-events</code>,
  752. * <code>DOMAttributeNameChanged</code>} is fired.
  753. * </li>
  754. * </ul>
  755. * @param n The node to rename.
  756. * @param namespaceURI The new namespace URI.
  757. * @param qualifiedName The new qualified name.
  758. * @return The renamed node. This is either the specified node or the new
  759. * node that was created to replace the specified node.
  760. * @exception DOMException
  761. * NOT_SUPPORTED_ERR: Raised when the type of the specified node is
  762. * neither <code>ELEMENT_NODE</code> nor <code>ATTRIBUTE_NODE</code>,
  763. * or if the implementation does not support the renaming of the
  764. * document element.
  765. * <br>INVALID_CHARACTER_ERR: Raised if the new qualified name is not an
  766. * XML name according to the XML version in use specified in the
  767. * <code>Document.xmlVersion</code> attribute.
  768. * <br>WRONG_DOCUMENT_ERR: Raised when the specified node was created
  769. * from a different document than this document.
  770. * <br>NAMESPACE_ERR: Raised if the <code>qualifiedName</code> is a
  771. * malformed qualified name, if the <code>qualifiedName</code> has a
  772. * prefix and the <code>namespaceURI</code> is <code>null</code>, or
  773. * if the <code>qualifiedName</code> has a prefix that is "xml" and
  774. * the <code>namespaceURI</code> is different from "<a href='http://www.w3.org/XML/1998/namespace'>
  775. * http://www.w3.org/XML/1998/namespace</a>" [<a href='http://www.w3.org/TR/1999/REC-xml-names-19990114/'>XML Namespaces</a>]
  776. * . Also raised, when the node being renamed is an attribute, if the
  777. * <code>qualifiedName</code>, or its prefix, is "xmlns" and the
  778. * <code>namespaceURI</code> is different from "<a href='http://www.w3.org/2000/xmlns/'>http://www.w3.org/2000/xmlns/</a>".
  779. * @since DOM Level 3
  780. */
  781. public Node renameNode(Node n,
  782. String namespaceURI,
  783. String qualifiedName)
  784. throws DOMException;
  785. }