001/*
002 * Copyright (c) 2004 World Wide Web Consortium,
003 *
004 * (Massachusetts Institute of Technology, European Research Consortium for
005 * Informatics and Mathematics, Keio University). All Rights Reserved. This
006 * work is distributed under the W3C(r) Software License [1] in the hope that
007 * it will be useful, but WITHOUT ANY WARRANTY; without even the implied
008 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
009 *
010 * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
011 */
012
013package org.w3c.dom;
014
015/**
016 * The <code>DOMImplementation</code> interface provides a number of methods
017 * for performing operations that are independent of any particular instance
018 * of the document object model.
019 * <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>.
020 */
021public interface DOMImplementation {
022    /**
023     * Test if the DOM implementation implements a specific feature and
024     * version, as specified in .
025     * @param feature  The name of the feature to test.
026     * @param version  This is the version number of the feature to test.
027     * @return <code>true</code> if the feature is implemented in the
028     *   specified version, <code>false</code> otherwise.
029     */
030    public boolean hasFeature(String feature,
031                              String version);
032
033    /**
034     * Creates an empty <code>DocumentType</code> node. Entity declarations
035     * and notations are not made available. Entity reference expansions and
036     * default attribute additions do not occur..
037     * @param qualifiedName The qualified name of the document type to be
038     *   created.
039     * @param publicId The external subset public identifier.
040     * @param systemId The external subset system identifier.
041     * @return A new <code>DocumentType</code> node with
042     *   <code>Node.ownerDocument</code> set to <code>null</code>.
043     * @exception DOMException
044     *   INVALID_CHARACTER_ERR: Raised if the specified qualified name is not
045     *   an XML name according to [<a href='http://www.w3.org/TR/2004/REC-xml-20040204'>XML 1.0</a>].
046     *   <br>NAMESPACE_ERR: Raised if the <code>qualifiedName</code> is
047     *   malformed.
048     *   <br>NOT_SUPPORTED_ERR: May be raised if the implementation does not
049     *   support the feature "XML" and the language exposed through the
050     *   Document does not support XML Namespaces (such as [<a href='http://www.w3.org/TR/1999/REC-html401-19991224/'>HTML 4.01</a>]).
051     * @since DOM Level 2
052     */
053    public DocumentType createDocumentType(String qualifiedName,
054                                           String publicId,
055                                           String systemId)
056                                           throws DOMException;
057
058    /**
059     * Creates a DOM Document object of the specified type with its document
060     * element.
061     * <br>Note that based on the <code>DocumentType</code> given to create
062     * the document, the implementation may instantiate specialized
063     * <code>Document</code> objects that support additional features than
064     * the "Core", such as "HTML" [<a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>DOM Level 2 HTML</a>]
065     * . On the other hand, setting the <code>DocumentType</code> after the
066     * document was created makes this very unlikely to happen.
067     * Alternatively, specialized <code>Document</code> creation methods,
068     * such as <code>createHTMLDocument</code> [<a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>DOM Level 2 HTML</a>]
069     * , can be used to obtain specific types of <code>Document</code>
070     * objects.
071     * @param namespaceURI The namespace URI of the document element to
072     *   create or <code>null</code>.
073     * @param qualifiedName The qualified name of the document element to be
074     *   created or <code>null</code>.
075     * @param doctype The type of document to be created or <code>null</code>.
076     *   When <code>doctype</code> is not <code>null</code>, its
077     *   <code>Node.ownerDocument</code> attribute is set to the document
078     *   being created.
079     * @return A new <code>Document</code> object with its document element.
080     *   If the <code>NamespaceURI</code>, <code>qualifiedName</code>, and
081     *   <code>doctype</code> are <code>null</code>, the returned
082     *   <code>Document</code> is empty with no document element.
083     * @exception DOMException
084     *   INVALID_CHARACTER_ERR: Raised if the specified qualified name is not
085     *   an XML name according to [<a href='http://www.w3.org/TR/2004/REC-xml-20040204'>XML 1.0</a>].
086     *   <br>NAMESPACE_ERR: Raised if the <code>qualifiedName</code> is
087     *   malformed, if the <code>qualifiedName</code> has a prefix and the
088     *   <code>namespaceURI</code> is <code>null</code>, or if the
089     *   <code>qualifiedName</code> is <code>null</code> and the
090     *   <code>namespaceURI</code> is different from <code>null</code>, or
091     *   if the <code>qualifiedName</code> has a prefix that is "xml" and
092     *   the <code>namespaceURI</code> is different from "<a href='http://www.w3.org/XML/1998/namespace'>
093     *   http://www.w3.org/XML/1998/namespace</a>" [<a href='http://www.w3.org/TR/1999/REC-xml-names-19990114/'>XML Namespaces</a>]
094     *   , or if the DOM implementation does not support the
095     *   <code>"XML"</code> feature but a non-null namespace URI was
096     *   provided, since namespaces were defined by XML.
097     *   <br>WRONG_DOCUMENT_ERR: Raised if <code>doctype</code> has already
098     *   been used with a different document or was created from a different
099     *   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     */
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     */
133    public Object getFeature(String feature,
134                             String version);
135
136}