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

Save This Page
Home » xmlbeans.090113 » org.w3c » dom » [javadoc | source]