1 /*
2  * Copyright (c) 2004 World Wide Web Consortium,
3  *
4  * (Massachusetts Institute of Technology, European Research Consortium for
5  * Informatics and Mathematics, Keio University). All Rights Reserved. This
6  * work is distributed under the W3C(r) Software License [1] in the hope that
7  * it will be useful, but WITHOUT ANY WARRANTY; without even the implied
8  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9  *
10  * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
11  */
12 
13 package org.w3c.dom;
14 
15 /**
16  * The <code>DOMImplementation</code> interface provides a number of methods
17  * for performing operations that are independent of any particular instance
18  * of the document object model.
19  * <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>.
20  */
21 public interface DOMImplementation {
22     /**
23      * Test if the DOM implementation implements a specific feature and
24      * version, as specified in .
25      * @param feature  The name of the feature to test.
26      * @param version  This is the version number of the feature to test.
27      * @return <code>true</code> if the feature is implemented in the
28      *   specified version, <code>false</code> otherwise.
29      */
hasFeature(String feature, String version)30     public boolean hasFeature(String feature,
31                               String version);
32 
33     /**
34      * Creates an empty <code>DocumentType</code> node. Entity declarations
35      * and notations are not made available. Entity reference expansions and
36      * default attribute additions do not occur..
37      * @param qualifiedName The qualified name of the document type to be
38      *   created.
39      * @param publicId The external subset public identifier.
40      * @param systemId The external subset system identifier.
41      * @return A new <code>DocumentType</code> node with
42      *   <code>Node.ownerDocument</code> set to <code>null</code>.
43      * @exception DOMException
44      *   INVALID_CHARACTER_ERR: Raised if the specified qualified name is not
45      *   an XML name according to [<a href='http://www.w3.org/TR/2004/REC-xml-20040204'>XML 1.0</a>].
46      *   <br>NAMESPACE_ERR: Raised if the <code>qualifiedName</code> is
47      *   malformed.
48      *   <br>NOT_SUPPORTED_ERR: May be raised if the implementation does not
49      *   support the feature "XML" and the language exposed through the
50      *   Document does not support XML Namespaces (such as [<a href='http://www.w3.org/TR/1999/REC-html401-19991224/'>HTML 4.01</a>]).
51      * @since DOM Level 2
52      */
createDocumentType(String qualifiedName, String publicId, String systemId)53     public DocumentType createDocumentType(String qualifiedName,
54                                            String publicId,
55                                            String systemId)
56                                            throws DOMException;
57 
58     /**
59      * Creates a DOM Document object of the specified type with its document
60      * element.
61      * <br>Note that based on the <code>DocumentType</code> given to create
62      * the document, the implementation may instantiate specialized
63      * <code>Document</code> objects that support additional features than
64      * the "Core", such as "HTML" [<a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>DOM Level 2 HTML</a>]
65      * . On the other hand, setting the <code>DocumentType</code> after the
66      * document was created makes this very unlikely to happen.
67      * Alternatively, specialized <code>Document</code> creation methods,
68      * such as <code>createHTMLDocument</code> [<a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>DOM Level 2 HTML</a>]
69      * , can be used to obtain specific types of <code>Document</code>
70      * objects.
71      * @param namespaceURI The namespace URI of the document element to
72      *   create or <code>null</code>.
73      * @param qualifiedName The qualified name of the document element to be
74      *   created or <code>null</code>.
75      * @param doctype The type of document to be created or <code>null</code>.
76      *   When <code>doctype</code> is not <code>null</code>, its
77      *   <code>Node.ownerDocument</code> attribute is set to the document
78      *   being created.
79      * @return A new <code>Document</code> object with its document element.
80      *   If the <code>NamespaceURI</code>, <code>qualifiedName</code>, and
81      *   <code>doctype</code> are <code>null</code>, the returned
82      *   <code>Document</code> is empty with no document element.
83      * @exception DOMException
84      *   INVALID_CHARACTER_ERR: Raised if the specified qualified name is not
85      *   an XML name according to [<a href='http://www.w3.org/TR/2004/REC-xml-20040204'>XML 1.0</a>].
86      *   <br>NAMESPACE_ERR: Raised if the <code>qualifiedName</code> is
87      *   malformed, if the <code>qualifiedName</code> has a prefix and the
88      *   <code>namespaceURI</code> is <code>null</code>, or if the
89      *   <code>qualifiedName</code> is <code>null</code> and the
90      *   <code>namespaceURI</code> is different from <code>null</code>, or
91      *   if the <code>qualifiedName</code> has a prefix that is "xml" and
92      *   the <code>namespaceURI</code> is different from "<a href='http://www.w3.org/XML/1998/namespace'>
93      *   http://www.w3.org/XML/1998/namespace</a>" [<a href='http://www.w3.org/TR/1999/REC-xml-names-19990114/'>XML Namespaces</a>]
94      *   , or if the DOM implementation does not support the
95      *   <code>"XML"</code> feature but a non-null namespace URI was
96      *   provided, since namespaces were defined by XML.
97      *   <br>WRONG_DOCUMENT_ERR: Raised if <code>doctype</code> has already
98      *   been used with a different document or was created from a different
99      *   implementation.
100      *   <br>NOT_SUPPORTED_ERR: May be raised if the implementation does not
101      *   support the feature "XML" and the language exposed through the
102      *   Document does not support XML Namespaces (such as [<a href='http://www.w3.org/TR/1999/REC-html401-19991224/'>HTML 4.01</a>]).
103      * @since DOM Level 2
104      */
createDocument(String namespaceURI, String qualifiedName, DocumentType doctype)105     public Document createDocument(String namespaceURI,
106                                    String qualifiedName,
107                                    DocumentType doctype)
108                                    throws DOMException;
109 
110     /**
111      *  This method returns a specialized object which implements the
112      * specialized APIs of the specified feature and version, as specified
113      * in . The specialized object may also be obtained by using
114      * binding-specific casting methods but is not necessarily expected to,
115      * as discussed in . This method also allow the implementation to
116      * provide specialized objects which do not support the
117      * <code>DOMImplementation</code> interface.
118      * @param feature  The name of the feature requested. Note that any plus
119      *   sign "+" prepended to the name of the feature will be ignored since
120      *   it is not significant in the context of this method.
121      * @param version  This is the version number of the feature to test.
122      * @return  Returns an object which implements the specialized APIs of
123      *   the specified feature and version, if any, or <code>null</code> if
124      *   there is no object which implements interfaces associated with that
125      *   feature. If the <code>DOMObject</code> returned by this method
126      *   implements the <code>DOMImplementation</code> interface, it must
127      *   delegate to the primary core <code>DOMImplementation</code> and not
128      *   return results inconsistent with the primary core
129      *   <code>DOMImplementation</code> such as <code>hasFeature</code>,
130      *   <code>getFeature</code>, etc.
131      * @since DOM Level 3
132      */
getFeature(String feature, String version)133     public Object getFeature(String feature,
134                              String version);
135 
136 }
137