OSDN Git Service

Add some org packages.
[pf3gnuchains/gcc-fork.git] / libjava / org / w3c / dom / Document.java
1 /*\r
2  * Copyright (c) 2000 World Wide Web Consortium,\r
3  * (Massachusetts Institute of Technology, Institut National de\r
4  * Recherche en Informatique et en Automatique, Keio University). All\r
5  * Rights Reserved. This program is distributed under the W3C's Software\r
6  * Intellectual Property License. This program is distributed in the\r
7  * hope that it will be useful, but WITHOUT ANY WARRANTY; without even\r
8  * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\r
9  * PURPOSE.\r
10  * See W3C License http://www.w3.org/Consortium/Legal/ for more details.\r
11  */\r
12 \r
13 package org.w3c.dom;\r
14 \r
15 /**\r
16  * The <code>Document</code> interface represents the entire HTML or XML \r
17  * document. Conceptually, it is the root of the document tree, and provides \r
18  * the primary access to the document's data.\r
19  * <p>Since elements, text nodes, comments, processing instructions, etc. \r
20  * cannot exist outside the context of a <code>Document</code>, the \r
21  * <code>Document</code> interface also contains the factory methods needed \r
22  * to create these objects. The <code>Node</code> objects created have a \r
23  * <code>ownerDocument</code> attribute which associates them with the \r
24  * <code>Document</code> within whose context they were created.\r
25  * <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113'>Document Object Model (DOM) Level 2 Core Specification</a>.\r
26  */\r
27 public interface Document extends Node {\r
28     /**\r
29      * The Document Type Declaration (see <code>DocumentType</code>) \r
30      * associated with this document. For HTML documents as well as XML \r
31      * documents without a document type declaration this returns \r
32      * <code>null</code>. The DOM Level 2 does not support editing the \r
33      * Document Type Declaration. <code>docType</code> cannot be altered in \r
34      * any way, including through the use of methods inherited from the \r
35      * <code>Node</code> interface, such as <code>insertNode</code> or \r
36      * <code>removeNode</code>.\r
37      */\r
38     public DocumentType getDoctype();\r
39 \r
40     /**\r
41      * The <code>DOMImplementation</code> object that handles this document. A \r
42      * DOM application may use objects from multiple implementations.\r
43      */\r
44     public DOMImplementation getImplementation();\r
45 \r
46     /**\r
47      * This is a convenience attribute that allows direct access to the child \r
48      * node that is the root element of the document. For HTML documents, \r
49      * this is the element with the tagName "HTML".\r
50      */\r
51     public Element getDocumentElement();\r
52 \r
53     /**\r
54      * Creates an element of the type specified. Note that the instance \r
55      * returned implements the <code>Element</code> interface, so attributes \r
56      * can be specified directly on the returned object.\r
57      * <br>In addition, if there are known attributes with default values, \r
58      * <code>Attr</code> nodes representing them are automatically created \r
59      * and attached to the element.\r
60      * <br>To create an element with a qualified name and namespace URI, use \r
61      * the <code>createElementNS</code> method.\r
62      * @param tagNameThe name of the element type to instantiate. For XML, \r
63      *   this is case-sensitive. For HTML, the <code>tagName</code> \r
64      *   parameter may be provided in any case, but it must be mapped to the \r
65      *   canonical uppercase form by the DOM implementation. \r
66      * @return A new <code>Element</code> object with the \r
67      *   <code>nodeName</code> attribute set to <code>tagName</code>, and \r
68      *   <code>localName</code>, <code>prefix</code>, and \r
69      *   <code>namespaceURI</code> set to <code>null</code>.\r
70      * @exception DOMException\r
71      *   INVALID_CHARACTER_ERR: Raised if the specified name contains an \r
72      *   illegal character.\r
73      */\r
74     public Element createElement(String tagName)\r
75                                  throws DOMException;\r
76 \r
77     /**\r
78      * Creates an empty <code>DocumentFragment</code> object. \r
79      * @return A new <code>DocumentFragment</code>.\r
80      */\r
81     public DocumentFragment createDocumentFragment();\r
82 \r
83     /**\r
84      * Creates a <code>Text</code> node given the specified string.\r
85      * @param dataThe data for the node.\r
86      * @return The new <code>Text</code> object.\r
87      */\r
88     public Text createTextNode(String data);\r
89 \r
90     /**\r
91      * Creates a <code>Comment</code> node given the specified string.\r
92      * @param dataThe data for the node.\r
93      * @return The new <code>Comment</code> object.\r
94      */\r
95     public Comment createComment(String data);\r
96 \r
97     /**\r
98      * Creates a <code>CDATASection</code> node whose value is the specified \r
99      * string.\r
100      * @param dataThe data for the <code>CDATASection</code> contents.\r
101      * @return The new <code>CDATASection</code> object.\r
102      * @exception DOMException\r
103      *   NOT_SUPPORTED_ERR: Raised if this document is an HTML document.\r
104      */\r
105     public CDATASection createCDATASection(String data)\r
106                                            throws DOMException;\r
107 \r
108     /**\r
109      * Creates a <code>ProcessingInstruction</code> node given the specified \r
110      * name and data strings.\r
111      * @param targetThe target part of the processing instruction.\r
112      * @param dataThe data for the node.\r
113      * @return The new <code>ProcessingInstruction</code> object.\r
114      * @exception DOMException\r
115      *   INVALID_CHARACTER_ERR: Raised if the specified target contains an \r
116      *   illegal character.\r
117      *   <br>NOT_SUPPORTED_ERR: Raised if this document is an HTML document.\r
118      */\r
119     public ProcessingInstruction createProcessingInstruction(String target, \r
120                                                              String data)\r
121                                                              throws DOMException;\r
122 \r
123     /**\r
124      * Creates an <code>Attr</code> of the given name. Note that the \r
125      * <code>Attr</code> instance can then be set on an <code>Element</code> \r
126      * using the <code>setAttributeNode</code> method. \r
127      * <br>To create an attribute with a qualified name and namespace URI, use \r
128      * the <code>createAttributeNS</code> method.\r
129      * @param nameThe name of the attribute.\r
130      * @return A new <code>Attr</code> object with the <code>nodeName</code> \r
131      *   attribute set to <code>name</code>, and <code>localName</code>, \r
132      *   <code>prefix</code>, and <code>namespaceURI</code> set to \r
133      *   <code>null</code>. The value of the attribute is the empty string.\r
134      * @exception DOMException\r
135      *   INVALID_CHARACTER_ERR: Raised if the specified name contains an \r
136      *   illegal character.\r
137      */\r
138     public Attr createAttribute(String name)\r
139                                 throws DOMException;\r
140 \r
141     /**\r
142      * Creates an <code>EntityReference</code> object. In addition, if the \r
143      * referenced entity is known, the child list of the \r
144      * <code>EntityReference</code> node is made the same as that of the \r
145      * corresponding <code>Entity</code> node.If any descendant of the \r
146      * <code>Entity</code> node has an unbound namespace prefix, the \r
147      * corresponding descendant of the created <code>EntityReference</code> \r
148      * node is also unbound; (its <code>namespaceURI</code> is \r
149      * <code>null</code>). The DOM Level 2 does not support any mechanism to \r
150      * resolve namespace prefixes.\r
151      * @param nameThe name of the entity to reference. \r
152      * @return The new <code>EntityReference</code> object.\r
153      * @exception DOMException\r
154      *   INVALID_CHARACTER_ERR: Raised if the specified name contains an \r
155      *   illegal character.\r
156      *   <br>NOT_SUPPORTED_ERR: Raised if this document is an HTML document.\r
157      */\r
158     public EntityReference createEntityReference(String name)\r
159                                                  throws DOMException;\r
160 \r
161     /**\r
162      * Returns a <code>NodeList</code> of all the <code>Elements</code> with a \r
163      * given tag name in the order in which they are encountered in a \r
164      * preorder traversal of the <code>Document</code> tree. \r
165      * @param tagnameThe name of the tag to match on. The special value "*" \r
166      *   matches all tags.\r
167      * @return A new <code>NodeList</code> object containing all the matched \r
168      *   <code>Elements</code>.\r
169      */\r
170     public NodeList getElementsByTagName(String tagname);\r
171 \r
172     /**\r
173      * Imports a node from another document to this document. The returned \r
174      * node has no parent; (<code>parentNode</code> is <code>null</code>). \r
175      * The source node is not altered or removed from the original document; \r
176      * this method creates a new copy of the source node.\r
177      * <br>For all nodes, importing a node creates a node object owned by the \r
178      * importing document, with attribute values identical to the source \r
179      * node's <code>nodeName</code> and <code>nodeType</code>, plus the \r
180      * attributes related to namespaces (<code>prefix</code>, \r
181      * <code>localName</code>, and <code>namespaceURI</code>). As in the \r
182      * <code>cloneNode</code> operation on a <code>Node</code>, the source \r
183      * node is not altered.\r
184      * <br>Additional information is copied as appropriate to the \r
185      * <code>nodeType</code>, attempting to mirror the behavior expected if \r
186      * a fragment of XML or HTML source was copied from one document to \r
187      * another, recognizing that the two documents may have different DTDs \r
188      * in the XML case. The following list describes the specifics for each \r
189      * type of node. \r
190      * <dl>\r
191      * <dt>ATTRIBUTE_NODE</dt>\r
192      * <dd>The <code>ownerElement</code> attribute \r
193      * is set to <code>null</code> and the <code>specified</code> flag is \r
194      * set to <code>true</code> on the generated <code>Attr</code>. The \r
195      * descendants of the source <code>Attr</code> are recursively imported \r
196      * and the resulting nodes reassembled to form the corresponding subtree.\r
197      * Note that the <code>deep</code> parameter has no effect on \r
198      * <code>Attr</code> nodes; they always carry their children with them \r
199      * when imported.</dd>\r
200      * <dt>DOCUMENT_FRAGMENT_NODE</dt>\r
201      * <dd>If the <code>deep</code> option \r
202      * was set to <code>true</code>, the descendants of the source element \r
203      * are recursively imported and the resulting nodes reassembled to form \r
204      * the corresponding subtree. Otherwise, this simply generates an empty \r
205      * <code>DocumentFragment</code>.</dd>\r
206      * <dt>DOCUMENT_NODE</dt>\r
207      * <dd><code>Document</code> \r
208      * nodes cannot be imported.</dd>\r
209      * <dt>DOCUMENT_TYPE_NODE</dt>\r
210      * <dd><code>DocumentType</code> \r
211      * nodes cannot be imported.</dd>\r
212      * <dt>ELEMENT_NODE</dt>\r
213      * <dd>Specified attribute nodes of the \r
214      * source element are imported, and the generated <code>Attr</code> \r
215      * nodes are attached to the generated <code>Element</code>. Default \r
216      * attributes are not copied, though if the document being imported into \r
217      * defines default attributes for this element name, those are assigned. \r
218      * If the <code>importNode</code> <code>deep</code> parameter was set to \r
219      * <code>true</code>, the descendants of the source element are \r
220      * recursively imported and the resulting nodes reassembled to form the \r
221      * corresponding subtree.</dd>\r
222      * <dt>ENTITY_NODE</dt>\r
223      * <dd><code>Entity</code> nodes can be \r
224      * imported, however in the current release of the DOM the \r
225      * <code>DocumentType</code> is readonly. Ability to add these imported \r
226      * nodes to a <code>DocumentType</code> will be considered for addition \r
227      * to a future release of the DOM.On import, the <code>publicId</code>, \r
228      * <code>systemId</code>, and <code>notationName</code> attributes are \r
229      * copied. If a <code>deep</code> import is requested, the descendants \r
230      * of the the source <code>Entity</code> are recursively imported and \r
231      * the resulting nodes reassembled to form the corresponding subtree.</dd>\r
232      * <dt>\r
233      * ENTITY_REFERENCE_NODE</dt>\r
234      * <dd>Only the <code>EntityReference</code> itself is \r
235      * copied, even if a <code>deep</code> import is requested, since the \r
236      * source and destination documents might have defined the entity \r
237      * differently. If the document being imported into provides a \r
238      * definition for this entity name, its value is assigned.</dd>\r
239      * <dt>NOTATION_NODE</dt>\r
240      * <dd>\r
241      * <code>Notation</code> nodes can be imported, however in the current \r
242      * release of the DOM the <code>DocumentType</code> is readonly. Ability \r
243      * to add these imported nodes to a <code>DocumentType</code> will be \r
244      * considered for addition to a future release of the DOM.On import, the \r
245      * <code>publicId</code> and <code>systemId</code> attributes are copied.\r
246      * Note that the <code>deep</code> parameter has no effect on \r
247      * <code>Notation</code> nodes since they never have any children.</dd>\r
248      * <dt>\r
249      * PROCESSING_INSTRUCTION_NODE</dt>\r
250      * <dd>The imported node copies its \r
251      * <code>target</code> and <code>data</code> values from those of the \r
252      * source node.</dd>\r
253      * <dt>TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODE</dt>\r
254      * <dd>These three \r
255      * types of nodes inheriting from <code>CharacterData</code> copy their \r
256      * <code>data</code> and <code>length</code> attributes from those of \r
257      * the source node.</dd>\r
258      *  \r
259      * @param importedNodeThe node to import.\r
260      * @param deepIf <code>true</code>, recursively import the subtree under \r
261      *   the specified node; if <code>false</code>, import only the node \r
262      *   itself, as explained above. This has no effect on <code>Attr</code>\r
263      *   , <code>EntityReference</code>, and <code>Notation</code> nodes.\r
264      * @return The imported node that belongs to this <code>Document</code>.\r
265      * @exception DOMException\r
266      *   NOT_SUPPORTED_ERR: Raised if the type of node being imported is not \r
267      *   supported.\r
268      * @since DOM Level 2\r
269      */\r
270     public Node importNode(Node importedNode, \r
271                            boolean deep)\r
272                            throws DOMException;\r
273 \r
274     /**\r
275      * Creates an element of the given qualified name and namespace URI. \r
276      * HTML-only DOM implementations do not need to implement this method.\r
277      * @param namespaceURIThe namespace URI of the element to create.\r
278      * @param qualifiedNameThe qualified name of the element type to \r
279      *   instantiate.\r
280      * @return A new <code>Element</code> object with the following \r
281      *   attributes:AttributeValue<code>Node.nodeName</code>\r
282      *   <code>qualifiedName</code><code>Node.namespaceURI</code>\r
283      *   <code>namespaceURI</code><code>Node.prefix</code>prefix, extracted \r
284      *   from <code>qualifiedName</code>, or <code>null</code> if there is \r
285      *   no prefix<code>Node.localName</code>local name, extracted from \r
286      *   <code>qualifiedName</code><code>Element.tagName</code>\r
287      *   <code>qualifiedName</code>\r
288      * @exception DOMException\r
289      *   INVALID_CHARACTER_ERR: Raised if the specified qualified name \r
290      *   contains an illegal character.\r
291      *   <br>NAMESPACE_ERR: Raised if the <code>qualifiedName</code> is \r
292      *   malformed, if the <code>qualifiedName</code> has a prefix and the \r
293      *   <code>namespaceURI</code> is <code>null</code>, or if the \r
294      *   <code>qualifiedName</code> has a prefix that is "xml" and the \r
295      *   <code>namespaceURI</code> is different from "\r
296      *   http://www.w3.org/XML/1998/namespace" .\r
297      * @since DOM Level 2\r
298      */\r
299     public Element createElementNS(String namespaceURI, \r
300                                    String qualifiedName)\r
301                                    throws DOMException;\r
302 \r
303     /**\r
304      * Creates an attribute of the given qualified name and namespace URI. \r
305      * HTML-only DOM implementations do not need to implement this method.\r
306      * @param namespaceURIThe namespace URI of the attribute to create.\r
307      * @param qualifiedNameThe qualified name of the attribute to instantiate.\r
308      * @return A new <code>Attr</code> object with the following attributes:\r
309      *   AttributeValue<code>Node.nodeName</code>qualifiedName\r
310      *   <code>Node.namespaceURI</code><code>namespaceURI</code>\r
311      *   <code>Node.prefix</code>prefix, extracted from \r
312      *   <code>qualifiedName</code>, or <code>null</code> if there is no \r
313      *   prefix<code>Node.localName</code>local name, extracted from \r
314      *   <code>qualifiedName</code><code>Attr.name</code>\r
315      *   <code>qualifiedName</code><code>Node.nodeValue</code>the empty \r
316      *   string\r
317      * @exception DOMException\r
318      *   INVALID_CHARACTER_ERR: Raised if the specified qualified name \r
319      *   contains an illegal character.\r
320      *   <br>NAMESPACE_ERR: Raised if the <code>qualifiedName</code> is \r
321      *   malformed, if the <code>qualifiedName</code> has a prefix and the \r
322      *   <code>namespaceURI</code> is <code>null</code>, if the \r
323      *   <code>qualifiedName</code> has a prefix that is "xml" and the \r
324      *   <code>namespaceURI</code> is different from "\r
325      *   http://www.w3.org/XML/1998/namespace", or if the \r
326      *   <code>qualifiedName</code> is "xmlns" and the \r
327      *   <code>namespaceURI</code> is different from "\r
328      *   http://www.w3.org/2000/xmlns/".\r
329      * @since DOM Level 2\r
330      */\r
331     public Attr createAttributeNS(String namespaceURI, \r
332                                   String qualifiedName)\r
333                                   throws DOMException;\r
334 \r
335     /**\r
336      * Returns a <code>NodeList</code> of all the <code>Elements</code> with a \r
337      * given local name and namespace URI in the order in which they are \r
338      * encountered in a preorder traversal of the <code>Document</code> tree.\r
339      * @param namespaceURIThe namespace URI of the elements to match on. The \r
340      *   special value "*" matches all namespaces.\r
341      * @param localNameThe local name of the elements to match on. The \r
342      *   special value "*" matches all local names.\r
343      * @return A new <code>NodeList</code> object containing all the matched \r
344      *   <code>Elements</code>.\r
345      * @since DOM Level 2\r
346      */\r
347     public NodeList getElementsByTagNameNS(String namespaceURI, \r
348                                            String localName);\r
349 \r
350     /**\r
351      * Returns the <code>Element</code> whose <code>ID</code> is given by \r
352      * <code>elementId</code>. If no such element exists, returns \r
353      * <code>null</code>. Behavior is not defined if more than one element \r
354      * has this <code>ID</code>. The DOM implementation must have \r
355      * information that says which attributes are of type ID. Attributes \r
356      * with the name "ID" are not of type ID unless so defined. \r
357      * Implementations that do not know whether attributes are of type ID or \r
358      * not are expected to return <code>null</code>.\r
359      * @param elementIdThe unique <code>id</code> value for an element.\r
360      * @return The matching element.\r
361      * @since DOM Level 2\r
362      */\r
363     public Element getElementById(String elementId);\r
364 \r
365 }\r