Path: blob/aarch64-shenandoah-jdk8u272-b10/jaxp/src/org/w3c/dom/Document.java
86409 views
/*1* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.2*3* This code is free software; you can redistribute it and/or modify it4* under the terms of the GNU General Public License version 2 only, as5* published by the Free Software Foundation. Oracle designates this6* particular file as subject to the "Classpath" exception as provided7* by Oracle in the LICENSE file that accompanied this code.8*9* This code is distributed in the hope that it will be useful, but WITHOUT10* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or11* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License12* version 2 for more details (a copy is included in the LICENSE file that13* accompanied this code).14*15* You should have received a copy of the GNU General Public License version16* 2 along with this work; if not, write to the Free Software Foundation,17* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.18*19* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA20* or visit www.oracle.com if you need additional information or have any21* questions.22*/2324/*25* This file is available under and governed by the GNU General Public26* License version 2 only, as published by the Free Software Foundation.27* However, the following notice accompanied the original version of this28* file and, per its terms, should not be removed:29*30* Copyright (c) 2004 World Wide Web Consortium,31*32* (Massachusetts Institute of Technology, European Research Consortium for33* Informatics and Mathematics, Keio University). All Rights Reserved. This34* work is distributed under the W3C(r) Software License [1] in the hope that35* it will be useful, but WITHOUT ANY WARRANTY; without even the implied36* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.37*38* [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-2002123139*/4041package org.w3c.dom;4243/**44* The <code>Document</code> interface represents the entire HTML or XML45* document. Conceptually, it is the root of the document tree, and provides46* the primary access to the document's data.47* <p>Since elements, text nodes, comments, processing instructions, etc.48* cannot exist outside the context of a <code>Document</code>, the49* <code>Document</code> interface also contains the factory methods needed50* to create these objects. The <code>Node</code> objects created have a51* <code>ownerDocument</code> attribute which associates them with the52* <code>Document</code> within whose context they were created.53* <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>.54*/55public interface Document extends Node {56/**57* The Document Type Declaration (see <code>DocumentType</code>)58* associated with this document. For XML documents without a document59* type declaration this returns <code>null</code>. For HTML documents,60* a <code>DocumentType</code> object may be returned, independently of61* the presence or absence of document type declaration in the HTML62* document.63* <br>This provides direct access to the <code>DocumentType</code> node,64* child node of this <code>Document</code>. This node can be set at65* document creation time and later changed through the use of child66* nodes manipulation methods, such as <code>Node.insertBefore</code>,67* or <code>Node.replaceChild</code>. Note, however, that while some68* implementations may instantiate different types of69* <code>Document</code> objects supporting additional features than the70* "Core", such as "HTML" [<a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>DOM Level 2 HTML</a>]71* , based on the <code>DocumentType</code> specified at creation time,72* changing it afterwards is very unlikely to result in a change of the73* features supported.74*75* @since DOM Level 376*/77public DocumentType getDoctype();7879/**80* The <code>DOMImplementation</code> object that handles this document. A81* DOM application may use objects from multiple implementations.82*/83public DOMImplementation getImplementation();8485/**86* This is a convenience attribute that allows direct access to the child87* node that is the document element of the document.88*/89public Element getDocumentElement();9091/**92* Creates an element of the type specified. Note that the instance93* returned implements the <code>Element</code> interface, so attributes94* can be specified directly on the returned object.95* <br>In addition, if there are known attributes with default values,96* <code>Attr</code> nodes representing them are automatically created97* and attached to the element.98* <br>To create an element with a qualified name and namespace URI, use99* the <code>createElementNS</code> method.100* @param tagName The name of the element type to instantiate. For XML,101* this is case-sensitive, otherwise it depends on the102* case-sensitivity of the markup language in use. In that case, the103* name is mapped to the canonical form of that markup by the DOM104* implementation.105* @return A new <code>Element</code> object with the106* <code>nodeName</code> attribute set to <code>tagName</code>, and107* <code>localName</code>, <code>prefix</code>, and108* <code>namespaceURI</code> set to <code>null</code>.109* @exception DOMException110* INVALID_CHARACTER_ERR: Raised if the specified name is not an XML111* name according to the XML version in use specified in the112* <code>Document.xmlVersion</code> attribute.113*/114public Element createElement(String tagName)115throws DOMException;116117/**118* Creates an empty <code>DocumentFragment</code> object.119* @return A new <code>DocumentFragment</code>.120*/121public DocumentFragment createDocumentFragment();122123/**124* Creates a <code>Text</code> node given the specified string.125* @param data The data for the node.126* @return The new <code>Text</code> object.127*/128public Text createTextNode(String data);129130/**131* Creates a <code>Comment</code> node given the specified string.132* @param data The data for the node.133* @return The new <code>Comment</code> object.134*/135public Comment createComment(String data);136137/**138* Creates a <code>CDATASection</code> node whose value is the specified139* string.140* @param data The data for the <code>CDATASection</code> contents.141* @return The new <code>CDATASection</code> object.142* @exception DOMException143* NOT_SUPPORTED_ERR: Raised if this document is an HTML document.144*/145public CDATASection createCDATASection(String data)146throws DOMException;147148/**149* Creates a <code>ProcessingInstruction</code> node given the specified150* name and data strings.151* @param target The target part of the processing instruction.Unlike152* <code>Document.createElementNS</code> or153* <code>Document.createAttributeNS</code>, no namespace well-formed154* checking is done on the target name. Applications should invoke155* <code>Document.normalizeDocument()</code> with the parameter "156* namespaces" set to <code>true</code> in order to ensure that the157* target name is namespace well-formed.158* @param data The data for the node.159* @return The new <code>ProcessingInstruction</code> object.160* @exception DOMException161* INVALID_CHARACTER_ERR: Raised if the specified target is not an XML162* name according to the XML version in use specified in the163* <code>Document.xmlVersion</code> attribute.164* <br>NOT_SUPPORTED_ERR: Raised if this document is an HTML document.165*/166public ProcessingInstruction createProcessingInstruction(String target,167String data)168throws DOMException;169170/**171* Creates an <code>Attr</code> of the given name. Note that the172* <code>Attr</code> instance can then be set on an <code>Element</code>173* using the <code>setAttributeNode</code> method.174* <br>To create an attribute with a qualified name and namespace URI, use175* the <code>createAttributeNS</code> method.176* @param name The name of the attribute.177* @return A new <code>Attr</code> object with the <code>nodeName</code>178* attribute set to <code>name</code>, and <code>localName</code>,179* <code>prefix</code>, and <code>namespaceURI</code> set to180* <code>null</code>. The value of the attribute is the empty string.181* @exception DOMException182* INVALID_CHARACTER_ERR: Raised if the specified name is not an XML183* name according to the XML version in use specified in the184* <code>Document.xmlVersion</code> attribute.185*/186public Attr createAttribute(String name)187throws DOMException;188189/**190* Creates an <code>EntityReference</code> object. In addition, if the191* referenced entity is known, the child list of the192* <code>EntityReference</code> node is made the same as that of the193* corresponding <code>Entity</code> node.194* <p ><b>Note:</b> If any descendant of the <code>Entity</code> node has195* an unbound namespace prefix, the corresponding descendant of the196* created <code>EntityReference</code> node is also unbound; (its197* <code>namespaceURI</code> is <code>null</code>). The DOM Level 2 and198* 3 do not support any mechanism to resolve namespace prefixes in this199* case.200* @param name The name of the entity to reference.Unlike201* <code>Document.createElementNS</code> or202* <code>Document.createAttributeNS</code>, no namespace well-formed203* checking is done on the entity name. Applications should invoke204* <code>Document.normalizeDocument()</code> with the parameter "205* namespaces" set to <code>true</code> in order to ensure that the206* entity name is namespace well-formed.207* @return The new <code>EntityReference</code> object.208* @exception DOMException209* INVALID_CHARACTER_ERR: Raised if the specified name is not an XML210* name according to the XML version in use specified in the211* <code>Document.xmlVersion</code> attribute.212* <br>NOT_SUPPORTED_ERR: Raised if this document is an HTML document.213*/214public EntityReference createEntityReference(String name)215throws DOMException;216217/**218* Returns a <code>NodeList</code> of all the <code>Elements</code> in219* document order with a given tag name and are contained in the220* document.221* @param tagname The name of the tag to match on. The special value "*"222* matches all tags. For XML, the <code>tagname</code> parameter is223* case-sensitive, otherwise it depends on the case-sensitivity of the224* markup language in use.225* @return A new <code>NodeList</code> object containing all the matched226* <code>Elements</code>.227*/228public NodeList getElementsByTagName(String tagname);229230/**231* Imports a node from another document to this document, without altering232* or removing the source node from the original document; this method233* creates a new copy of the source node. The returned node has no234* parent; (<code>parentNode</code> is <code>null</code>).235* <br>For all nodes, importing a node creates a node object owned by the236* importing document, with attribute values identical to the source237* node's <code>nodeName</code> and <code>nodeType</code>, plus the238* attributes related to namespaces (<code>prefix</code>,239* <code>localName</code>, and <code>namespaceURI</code>). As in the240* <code>cloneNode</code> operation, the source node is not altered.241* User data associated to the imported node is not carried over.242* However, if any <code>UserDataHandlers</code> has been specified243* along with the associated data these handlers will be called with the244* appropriate parameters before this method returns.245* <br>Additional information is copied as appropriate to the246* <code>nodeType</code>, attempting to mirror the behavior expected if247* a fragment of XML or HTML source was copied from one document to248* another, recognizing that the two documents may have different DTDs249* in the XML case. The following list describes the specifics for each250* type of node.251* <dl>252* <dt>ATTRIBUTE_NODE</dt>253* <dd>The <code>ownerElement</code> attribute254* is set to <code>null</code> and the <code>specified</code> flag is255* set to <code>true</code> on the generated <code>Attr</code>. The256* descendants of the source <code>Attr</code> are recursively imported257* and the resulting nodes reassembled to form the corresponding subtree.258* Note that the <code>deep</code> parameter has no effect on259* <code>Attr</code> nodes; they always carry their children with them260* when imported.</dd>261* <dt>DOCUMENT_FRAGMENT_NODE</dt>262* <dd>If the <code>deep</code> option263* was set to <code>true</code>, the descendants of the source264* <code>DocumentFragment</code> are recursively imported and the265* resulting nodes reassembled under the imported266* <code>DocumentFragment</code> to form the corresponding subtree.267* Otherwise, this simply generates an empty268* <code>DocumentFragment</code>.</dd>269* <dt>DOCUMENT_NODE</dt>270* <dd><code>Document</code>271* nodes cannot be imported.</dd>272* <dt>DOCUMENT_TYPE_NODE</dt>273* <dd><code>DocumentType</code>274* nodes cannot be imported.</dd>275* <dt>ELEMENT_NODE</dt>276* <dd><em>Specified</em> attribute nodes of the source element are imported, and the generated277* <code>Attr</code> nodes are attached to the generated278* <code>Element</code>. Default attributes are <em>not</em> copied, though if the document being imported into defines default279* attributes for this element name, those are assigned. If the280* <code>importNode</code> <code>deep</code> parameter was set to281* <code>true</code>, the descendants of the source element are282* recursively imported and the resulting nodes reassembled to form the283* corresponding subtree.</dd>284* <dt>ENTITY_NODE</dt>285* <dd><code>Entity</code> nodes can be286* imported, however in the current release of the DOM the287* <code>DocumentType</code> is readonly. Ability to add these imported288* nodes to a <code>DocumentType</code> will be considered for addition289* to a future release of the DOM.On import, the <code>publicId</code>,290* <code>systemId</code>, and <code>notationName</code> attributes are291* copied. If a <code>deep</code> import is requested, the descendants292* of the the source <code>Entity</code> are recursively imported and293* the resulting nodes reassembled to form the corresponding subtree.</dd>294* <dt>295* ENTITY_REFERENCE_NODE</dt>296* <dd>Only the <code>EntityReference</code> itself is297* copied, even if a <code>deep</code> import is requested, since the298* source and destination documents might have defined the entity299* differently. If the document being imported into provides a300* definition for this entity name, its value is assigned.</dd>301* <dt>NOTATION_NODE</dt>302* <dd>303* <code>Notation</code> nodes can be imported, however in the current304* release of the DOM the <code>DocumentType</code> is readonly. Ability305* to add these imported nodes to a <code>DocumentType</code> will be306* considered for addition to a future release of the DOM.On import, the307* <code>publicId</code> and <code>systemId</code> attributes are copied.308* Note that the <code>deep</code> parameter has no effect on this type309* of nodes since they cannot have any children.</dd>310* <dt>311* PROCESSING_INSTRUCTION_NODE</dt>312* <dd>The imported node copies its313* <code>target</code> and <code>data</code> values from those of the314* source node.Note that the <code>deep</code> parameter has no effect315* on this type of nodes since they cannot have any children.</dd>316* <dt>TEXT_NODE,317* CDATA_SECTION_NODE, COMMENT_NODE</dt>318* <dd>These three types of nodes inheriting319* from <code>CharacterData</code> copy their <code>data</code> and320* <code>length</code> attributes from those of the source node.Note321* that the <code>deep</code> parameter has no effect on these types of322* nodes since they cannot have any children.</dd>323* </dl>324* @param importedNode The node to import.325* @param deep If <code>true</code>, recursively import the subtree under326* the specified node; if <code>false</code>, import only the node327* itself, as explained above. This has no effect on nodes that cannot328* have any children, and on <code>Attr</code>, and329* <code>EntityReference</code> nodes.330* @return The imported node that belongs to this <code>Document</code>.331* @exception DOMException332* NOT_SUPPORTED_ERR: Raised if the type of node being imported is not333* supported.334* <br>INVALID_CHARACTER_ERR: Raised if one of the imported names is not335* an XML name according to the XML version in use specified in the336* <code>Document.xmlVersion</code> attribute. This may happen when337* importing an XML 1.1 [<a href='http://www.w3.org/TR/2004/REC-xml11-20040204/'>XML 1.1</a>] element338* into an XML 1.0 document, for instance.339* @since DOM Level 2340*/341public Node importNode(Node importedNode,342boolean deep)343throws DOMException;344345/**346* Creates an element of the given qualified name and namespace URI.347* <br>Per [<a href='http://www.w3.org/TR/1999/REC-xml-names-19990114/'>XML Namespaces</a>]348* , applications must use the value <code>null</code> as the349* namespaceURI parameter for methods if they wish to have no namespace.350* @param namespaceURI The namespace URI of the element to create.351* @param qualifiedName The qualified name of the element type to352* instantiate.353* @return A new <code>Element</code> object with the following354* attributes:355* <table border='1' cellpadding='3'>356* <tr>357* <th>Attribute</th>358* <th>Value</th>359* </tr>360* <tr>361* <td valign='top' rowspan='1' colspan='1'><code>Node.nodeName</code></td>362* <td valign='top' rowspan='1' colspan='1'>363* <code>qualifiedName</code></td>364* </tr>365* <tr>366* <td valign='top' rowspan='1' colspan='1'><code>Node.namespaceURI</code></td>367* <td valign='top' rowspan='1' colspan='1'>368* <code>namespaceURI</code></td>369* </tr>370* <tr>371* <td valign='top' rowspan='1' colspan='1'><code>Node.prefix</code></td>372* <td valign='top' rowspan='1' colspan='1'>prefix, extracted373* from <code>qualifiedName</code>, or <code>null</code> if there is374* no prefix</td>375* </tr>376* <tr>377* <td valign='top' rowspan='1' colspan='1'><code>Node.localName</code></td>378* <td valign='top' rowspan='1' colspan='1'>local name, extracted from379* <code>qualifiedName</code></td>380* </tr>381* <tr>382* <td valign='top' rowspan='1' colspan='1'><code>Element.tagName</code></td>383* <td valign='top' rowspan='1' colspan='1'>384* <code>qualifiedName</code></td>385* </tr>386* </table>387* @exception DOMException388* INVALID_CHARACTER_ERR: Raised if the specified389* <code>qualifiedName</code> is not an XML name according to the XML390* version in use specified in the <code>Document.xmlVersion</code>391* attribute.392* <br>NAMESPACE_ERR: Raised if the <code>qualifiedName</code> is a393* malformed qualified name, if the <code>qualifiedName</code> has a394* prefix and the <code>namespaceURI</code> is <code>null</code>, or395* if the <code>qualifiedName</code> has a prefix that is "xml" and396* the <code>namespaceURI</code> is different from "<a href='http://www.w3.org/XML/1998/namespace'>397* http://www.w3.org/XML/1998/namespace</a>" [<a href='http://www.w3.org/TR/1999/REC-xml-names-19990114/'>XML Namespaces</a>]398* , or if the <code>qualifiedName</code> or its prefix is "xmlns" and399* 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".400* <br>NOT_SUPPORTED_ERR: Always thrown if the current document does not401* support the <code>"XML"</code> feature, since namespaces were402* defined by XML.403* @since DOM Level 2404*/405public Element createElementNS(String namespaceURI,406String qualifiedName)407throws DOMException;408409/**410* Creates an attribute of the given qualified name and namespace URI.411* <br>Per [<a href='http://www.w3.org/TR/1999/REC-xml-names-19990114/'>XML Namespaces</a>]412* , applications must use the value <code>null</code> as the413* <code>namespaceURI</code> parameter for methods if they wish to have414* no namespace.415* @param namespaceURI The namespace URI of the attribute to create.416* @param qualifiedName The qualified name of the attribute to417* instantiate.418* @return A new <code>Attr</code> object with the following attributes:419* <table border='1' cellpadding='3'>420* <tr>421* <th>422* Attribute</th>423* <th>Value</th>424* </tr>425* <tr>426* <td valign='top' rowspan='1' colspan='1'><code>Node.nodeName</code></td>427* <td valign='top' rowspan='1' colspan='1'>qualifiedName</td>428* </tr>429* <tr>430* <td valign='top' rowspan='1' colspan='1'>431* <code>Node.namespaceURI</code></td>432* <td valign='top' rowspan='1' colspan='1'><code>namespaceURI</code></td>433* </tr>434* <tr>435* <td valign='top' rowspan='1' colspan='1'>436* <code>Node.prefix</code></td>437* <td valign='top' rowspan='1' colspan='1'>prefix, extracted from438* <code>qualifiedName</code>, or <code>null</code> if there is no439* prefix</td>440* </tr>441* <tr>442* <td valign='top' rowspan='1' colspan='1'><code>Node.localName</code></td>443* <td valign='top' rowspan='1' colspan='1'>local name, extracted from444* <code>qualifiedName</code></td>445* </tr>446* <tr>447* <td valign='top' rowspan='1' colspan='1'><code>Attr.name</code></td>448* <td valign='top' rowspan='1' colspan='1'>449* <code>qualifiedName</code></td>450* </tr>451* <tr>452* <td valign='top' rowspan='1' colspan='1'><code>Node.nodeValue</code></td>453* <td valign='top' rowspan='1' colspan='1'>the empty454* string</td>455* </tr>456* </table>457* @exception DOMException458* INVALID_CHARACTER_ERR: Raised if the specified459* <code>qualifiedName</code> is not an XML name according to the XML460* version in use specified in the <code>Document.xmlVersion</code>461* attribute.462* <br>NAMESPACE_ERR: Raised if the <code>qualifiedName</code> is a463* malformed qualified name, if the <code>qualifiedName</code> has a464* prefix and the <code>namespaceURI</code> is <code>null</code>, if465* the <code>qualifiedName</code> has a prefix that is "xml" and the466* <code>namespaceURI</code> is different from "<a href='http://www.w3.org/XML/1998/namespace'>467* http://www.w3.org/XML/1998/namespace</a>", if the <code>qualifiedName</code> or its prefix is "xmlns" and the468* <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".469* <br>NOT_SUPPORTED_ERR: Always thrown if the current document does not470* support the <code>"XML"</code> feature, since namespaces were471* defined by XML.472* @since DOM Level 2473*/474public Attr createAttributeNS(String namespaceURI,475String qualifiedName)476throws DOMException;477478/**479* Returns a <code>NodeList</code> of all the <code>Elements</code> with a480* given local name and namespace URI in document order.481* @param namespaceURI The namespace URI of the elements to match on. The482* special value <code>"*"</code> matches all namespaces.483* @param localName The local name of the elements to match on. The484* special value "*" matches all local names.485* @return A new <code>NodeList</code> object containing all the matched486* <code>Elements</code>.487* @since DOM Level 2488*/489public NodeList getElementsByTagNameNS(String namespaceURI,490String localName);491492/**493* Returns the <code>Element</code> that has an ID attribute with the494* given value. If no such element exists, this returns <code>null</code>495* . If more than one element has an ID attribute with that value, what496* is returned is undefined.497* <br> The DOM implementation is expected to use the attribute498* <code>Attr.isId</code> to determine if an attribute is of type ID.499* <p ><b>Note:</b> Attributes with the name "ID" or "id" are not of type500* ID unless so defined.501* @param elementId The unique <code>id</code> value for an element.502* @return The matching element or <code>null</code> if there is none.503* @since DOM Level 2504*/505public Element getElementById(String elementId);506507/**508* An attribute specifying the encoding used for this document at the time509* of the parsing. This is <code>null</code> when it is not known, such510* as when the <code>Document</code> was created in memory.511* @since DOM Level 3512*/513public String getInputEncoding();514515/**516* 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> when517* unspecified or when it is not known, such as when the518* <code>Document</code> was created in memory.519* @since DOM Level 3520*/521public String getXmlEncoding();522523/**524* 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> when525* unspecified.526* <p ><b>Note:</b> No verification is done on the value when setting527* this attribute. Applications should use528* <code>Document.normalizeDocument()</code> with the "validate"529* parameter to verify if the value matches the <a href='http://www.w3.org/TR/2004/REC-xml-20040204#sec-rmd'>validity530* constraint for standalone document declaration</a> as defined in [<a href='http://www.w3.org/TR/2004/REC-xml-20040204'>XML 1.0</a>].531* @since DOM Level 3532*/533public boolean getXmlStandalone();534/**535* 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> when536* unspecified.537* <p ><b>Note:</b> No verification is done on the value when setting538* this attribute. Applications should use539* <code>Document.normalizeDocument()</code> with the "validate"540* parameter to verify if the value matches the <a href='http://www.w3.org/TR/2004/REC-xml-20040204#sec-rmd'>validity541* constraint for standalone document declaration</a> as defined in [<a href='http://www.w3.org/TR/2004/REC-xml-20040204'>XML 1.0</a>].542* @exception DOMException543* NOT_SUPPORTED_ERR: Raised if this document does not support the544* "XML" feature.545* @since DOM Level 3546*/547public void setXmlStandalone(boolean xmlStandalone)548throws DOMException;549550/**551* 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 if552* this document supports the "XML" feature, the value is553* <code>"1.0"</code>. If this document does not support the "XML"554* feature, the value is always <code>null</code>. Changing this555* attribute will affect methods that check for invalid characters in556* XML names. Application should invoke557* <code>Document.normalizeDocument()</code> in order to check for558* invalid characters in the <code>Node</code>s that are already part of559* this <code>Document</code>.560* <br> DOM applications may use the561* <code>DOMImplementation.hasFeature(feature, version)</code> method562* with parameter values "XMLVersion" and "1.0" (respectively) to563* determine if an implementation supports [<a href='http://www.w3.org/TR/2004/REC-xml-20040204'>XML 1.0</a>]. DOM564* applications may use the same method with parameter values565* "XMLVersion" and "1.1" (respectively) to determine if an566* implementation supports [<a href='http://www.w3.org/TR/2004/REC-xml11-20040204/'>XML 1.1</a>]. In both567* cases, in order to support XML, an implementation must also support568* the "XML" feature defined in this specification. <code>Document</code>569* objects supporting a version of the "XMLVersion" feature must not570* raise a <code>NOT_SUPPORTED_ERR</code> exception for the same version571* number when using <code>Document.xmlVersion</code>.572* @since DOM Level 3573*/574public String getXmlVersion();575/**576* 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 if577* this document supports the "XML" feature, the value is578* <code>"1.0"</code>. If this document does not support the "XML"579* feature, the value is always <code>null</code>. Changing this580* attribute will affect methods that check for invalid characters in581* XML names. Application should invoke582* <code>Document.normalizeDocument()</code> in order to check for583* invalid characters in the <code>Node</code>s that are already part of584* this <code>Document</code>.585* <br> DOM applications may use the586* <code>DOMImplementation.hasFeature(feature, version)</code> method587* with parameter values "XMLVersion" and "1.0" (respectively) to588* determine if an implementation supports [<a href='http://www.w3.org/TR/2004/REC-xml-20040204'>XML 1.0</a>]. DOM589* applications may use the same method with parameter values590* "XMLVersion" and "1.1" (respectively) to determine if an591* implementation supports [<a href='http://www.w3.org/TR/2004/REC-xml11-20040204/'>XML 1.1</a>]. In both592* cases, in order to support XML, an implementation must also support593* the "XML" feature defined in this specification. <code>Document</code>594* objects supporting a version of the "XMLVersion" feature must not595* raise a <code>NOT_SUPPORTED_ERR</code> exception for the same version596* number when using <code>Document.xmlVersion</code>.597* @exception DOMException598* NOT_SUPPORTED_ERR: Raised if the version is set to a value that is599* not supported by this <code>Document</code> or if this document600* does not support the "XML" feature.601* @since DOM Level 3602*/603public void setXmlVersion(String xmlVersion)604throws DOMException;605606/**607* An attribute specifying whether error checking is enforced or not. When608* set to <code>false</code>, the implementation is free to not test609* every possible error case normally defined on DOM operations, and not610* raise any <code>DOMException</code> on DOM operations or report611* errors while using <code>Document.normalizeDocument()</code>. In case612* of error, the behavior is undefined. This attribute is613* <code>true</code> by default.614* @since DOM Level 3615*/616public boolean getStrictErrorChecking();617/**618* An attribute specifying whether error checking is enforced or not. When619* set to <code>false</code>, the implementation is free to not test620* every possible error case normally defined on DOM operations, and not621* raise any <code>DOMException</code> on DOM operations or report622* errors while using <code>Document.normalizeDocument()</code>. In case623* of error, the behavior is undefined. This attribute is624* <code>true</code> by default.625* @since DOM Level 3626*/627public void setStrictErrorChecking(boolean strictErrorChecking);628629/**630* The location of the document or <code>null</code> if undefined or if631* the <code>Document</code> was created using632* <code>DOMImplementation.createDocument</code>. No lexical checking is633* performed when setting this attribute; this could result in a634* <code>null</code> value returned when using <code>Node.baseURI</code>635* .636* <br> Beware that when the <code>Document</code> supports the feature637* "HTML" [<a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>DOM Level 2 HTML</a>]638* , the href attribute of the HTML BASE element takes precedence over639* this attribute when computing <code>Node.baseURI</code>.640* @since DOM Level 3641*/642public String getDocumentURI();643/**644* The location of the document or <code>null</code> if undefined or if645* the <code>Document</code> was created using646* <code>DOMImplementation.createDocument</code>. No lexical checking is647* performed when setting this attribute; this could result in a648* <code>null</code> value returned when using <code>Node.baseURI</code>649* .650* <br> Beware that when the <code>Document</code> supports the feature651* "HTML" [<a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>DOM Level 2 HTML</a>]652* , the href attribute of the HTML BASE element takes precedence over653* this attribute when computing <code>Node.baseURI</code>.654* @since DOM Level 3655*/656public void setDocumentURI(String documentURI);657658/**659* Attempts to adopt a node from another document to this document. If660* supported, it changes the <code>ownerDocument</code> of the source661* node, its children, as well as the attached attribute nodes if there662* are any. If the source node has a parent it is first removed from the663* child list of its parent. This effectively allows moving a subtree664* from one document to another (unlike <code>importNode()</code> which665* create a copy of the source node instead of moving it). When it666* fails, applications should use <code>Document.importNode()</code>667* instead. Note that if the adopted node is already part of this668* document (i.e. the source and target document are the same), this669* method still has the effect of removing the source node from the670* child list of its parent, if any. The following list describes the671* specifics for each type of node.672* <dl>673* <dt>ATTRIBUTE_NODE</dt>674* <dd>The675* <code>ownerElement</code> attribute is set to <code>null</code> and676* the <code>specified</code> flag is set to <code>true</code> on the677* adopted <code>Attr</code>. The descendants of the source678* <code>Attr</code> are recursively adopted.</dd>679* <dt>DOCUMENT_FRAGMENT_NODE</dt>680* <dd>The681* descendants of the source node are recursively adopted.</dd>682* <dt>DOCUMENT_NODE</dt>683* <dd>684* <code>Document</code> nodes cannot be adopted.</dd>685* <dt>DOCUMENT_TYPE_NODE</dt>686* <dd>687* <code>DocumentType</code> nodes cannot be adopted.</dd>688* <dt>ELEMENT_NODE</dt>689* <dd><em>Specified</em> attribute nodes of the source element are adopted. Default attributes690* are discarded, though if the document being adopted into defines691* default attributes for this element name, those are assigned. The692* descendants of the source element are recursively adopted.</dd>693* <dt>ENTITY_NODE</dt>694* <dd>695* <code>Entity</code> nodes cannot be adopted.</dd>696* <dt>ENTITY_REFERENCE_NODE</dt>697* <dd>Only698* the <code>EntityReference</code> node itself is adopted, the699* descendants are discarded, since the source and destination documents700* might have defined the entity differently. If the document being701* imported into provides a definition for this entity name, its value702* is assigned.</dd>703* <dt>NOTATION_NODE</dt>704* <dd><code>Notation</code> nodes cannot be705* adopted.</dd>706* <dt>PROCESSING_INSTRUCTION_NODE, TEXT_NODE, CDATA_SECTION_NODE,707* COMMENT_NODE</dt>708* <dd>These nodes can all be adopted. No specifics.</dd>709* </dl>710* <p ><b>Note:</b> Since it does not create new nodes unlike the711* <code>Document.importNode()</code> method, this method does not raise712* an <code>INVALID_CHARACTER_ERR</code> exception, and applications713* should use the <code>Document.normalizeDocument()</code> method to714* check if an imported name is not an XML name according to the XML715* version in use.716* @param source The node to move into this document.717* @return The adopted node, or <code>null</code> if this operation718* fails, such as when the source node comes from a different719* implementation.720* @exception DOMException721* NOT_SUPPORTED_ERR: Raised if the source node is of type722* <code>DOCUMENT</code>, <code>DOCUMENT_TYPE</code>.723* <br>NO_MODIFICATION_ALLOWED_ERR: Raised when the source node is724* readonly.725* @since DOM Level 3726*/727public Node adoptNode(Node source)728throws DOMException;729730/**731* The configuration used when <code>Document.normalizeDocument()</code>732* is invoked.733* @since DOM Level 3734*/735public DOMConfiguration getDomConfig();736737/**738* This method acts as if the document was going through a save and load739* cycle, putting the document in a "normal" form. As a consequence,740* this method updates the replacement tree of741* <code>EntityReference</code> nodes and normalizes <code>Text</code>742* nodes, as defined in the method <code>Node.normalize()</code>.743* <br> Otherwise, the actual result depends on the features being set on744* the <code>Document.domConfig</code> object and governing what745* operations actually take place. Noticeably this method could also746* make the document namespace well-formed according to the algorithm747* described in , check the character normalization, remove the748* <code>CDATASection</code> nodes, etc. See749* <code>DOMConfiguration</code> for details.750* <pre>// Keep in the document751* the information defined // in the XML Information Set (Java example)752* DOMConfiguration docConfig = myDocument.getDomConfig();753* docConfig.setParameter("infoset", Boolean.TRUE);754* myDocument.normalizeDocument();</pre>755*756* <br>Mutation events, when supported, are generated to reflect the757* changes occurring on the document.758* <br> If errors occur during the invocation of this method, such as an759* attempt to update a read-only node or a <code>Node.nodeName</code>760* contains an invalid character according to the XML version in use,761* errors or warnings (<code>DOMError.SEVERITY_ERROR</code> or762* <code>DOMError.SEVERITY_WARNING</code>) will be reported using the763* <code>DOMErrorHandler</code> object associated with the "error-handler764* " parameter. Note this method might also report fatal errors (765* <code>DOMError.SEVERITY_FATAL_ERROR</code>) if an implementation766* cannot recover from an error.767* @since DOM Level 3768*/769public void normalizeDocument();770771/**772* Rename an existing node of type <code>ELEMENT_NODE</code> or773* <code>ATTRIBUTE_NODE</code>.774* <br>When possible this simply changes the name of the given node,775* otherwise this creates a new node with the specified name and776* replaces the existing node with the new node as described below.777* <br>If simply changing the name of the given node is not possible, the778* following operations are performed: a new node is created, any779* registered event listener is registered on the new node, any user780* data attached to the old node is removed from that node, the old node781* is removed from its parent if it has one, the children are moved to782* the new node, if the renamed node is an <code>Element</code> its783* attributes are moved to the new node, the new node is inserted at the784* position the old node used to have in its parent's child nodes list785* if it has one, the user data that was attached to the old node is786* attached to the new node.787* <br>When the node being renamed is an <code>Element</code> only the788* specified attributes are moved, default attributes originated from789* the DTD are updated according to the new element name. In addition,790* the implementation may update default attributes from other schemas.791* Applications should use <code>Document.normalizeDocument()</code> to792* guarantee these attributes are up-to-date.793* <br>When the node being renamed is an <code>Attr</code> that is794* attached to an <code>Element</code>, the node is first removed from795* the <code>Element</code> attributes map. Then, once renamed, either796* by modifying the existing node or creating a new one as described797* above, it is put back.798* <br>In addition,799* <ul>800* <li> a user data event <code>NODE_RENAMED</code> is fired,801* </li>802* <li>803* when the implementation supports the feature "MutationNameEvents",804* each mutation operation involved in this method fires the appropriate805* event, and in the end the event {806* <code>http://www.w3.org/2001/xml-events</code>,807* <code>DOMElementNameChanged</code>} or {808* <code>http://www.w3.org/2001/xml-events</code>,809* <code>DOMAttributeNameChanged</code>} is fired.810* </li>811* </ul>812* @param n The node to rename.813* @param namespaceURI The new namespace URI.814* @param qualifiedName The new qualified name.815* @return The renamed node. This is either the specified node or the new816* node that was created to replace the specified node.817* @exception DOMException818* NOT_SUPPORTED_ERR: Raised when the type of the specified node is819* neither <code>ELEMENT_NODE</code> nor <code>ATTRIBUTE_NODE</code>,820* or if the implementation does not support the renaming of the821* document element.822* <br>INVALID_CHARACTER_ERR: Raised if the new qualified name is not an823* XML name according to the XML version in use specified in the824* <code>Document.xmlVersion</code> attribute.825* <br>WRONG_DOCUMENT_ERR: Raised when the specified node was created826* from a different document than this document.827* <br>NAMESPACE_ERR: Raised if the <code>qualifiedName</code> is a828* malformed qualified name, if the <code>qualifiedName</code> has a829* prefix and the <code>namespaceURI</code> is <code>null</code>, or830* if the <code>qualifiedName</code> has a prefix that is "xml" and831* the <code>namespaceURI</code> is different from "<a href='http://www.w3.org/XML/1998/namespace'>832* http://www.w3.org/XML/1998/namespace</a>" [<a href='http://www.w3.org/TR/1999/REC-xml-names-19990114/'>XML Namespaces</a>]833* . Also raised, when the node being renamed is an attribute, if the834* <code>qualifiedName</code>, or its prefix, is "xmlns" and the835* <code>namespaceURI</code> is different from "<a href='http://www.w3.org/2000/xmlns/'>http://www.w3.org/2000/xmlns/</a>".836* @since DOM Level 3837*/838public Node renameNode(Node n,839String namespaceURI,840String qualifiedName)841throws DOMException;842843}844845846