2
* Licensed to the Apache Software Foundation (ASF) under one or more
3
* contributor license agreements. See the NOTICE file distributed with
4
* this work for additional information regarding copyright ownership.
5
* The ASF licenses this file to You under the Apache License, Version 2.0
6
* (the "License"); you may not use this file except in compliance with
7
* the License. You may obtain a copy of the License at
9
* http://www.apache.org/licenses/LICENSE-2.0
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
18
package org.apache.xerces.dom;
20
import org.w3c.dom.DOMException;
21
import org.w3c.dom.DOMImplementation;
22
import org.w3c.dom.Document;
23
import org.w3c.dom.DocumentType;
24
import org.w3c.dom.Element;
27
* The DOMImplementation class is description of a particular
28
* implementation of the Document Object Model. As such its data is
29
* static, shared by all instances of this implementation.
31
* The DOM API requires that it be a real object rather than static
32
* methods. However, there's nothing that says it can't be a singleton,
33
* so that's how I've implemented it.
37
* @version $Id: PSVIDOMImplementationImpl.java,v 1.2 2009/12/10 03:18:32 matthewoliver Exp $
38
* @since PR-DOM-Level-1-19980818.
40
public class PSVIDOMImplementationImpl extends CoreDOMImplementationImpl {
48
/** Dom implementation singleton. */
49
static PSVIDOMImplementationImpl singleton = new PSVIDOMImplementationImpl();
55
/** NON-DOM: Obtain and return the single shared object */
56
public static DOMImplementation getDOMImplementation() {
61
// DOMImplementation methods
65
* Test if the DOM implementation supports a specific "feature" --
66
* currently meaning language and level thereof.
68
* @param feature The package name of the feature to test.
69
* In Level 1, supported values are "HTML" and "XML" (case-insensitive).
70
* At this writing, org.apache.xerces.dom supports only XML.
72
* @param version The version number of the feature being tested.
73
* This is interpreted as "Version of the DOM API supported for the
74
* specified Feature", and in Level 1 should be "1.0"
76
* @return true iff this implementation is compatable with the specified
77
* feature and version.
79
public boolean hasFeature(String feature, String version) {
80
return super.hasFeature(feature, version) ||
81
feature.equalsIgnoreCase("psvi");
82
} // hasFeature(String,String):boolean
85
* Introduced in DOM Level 2. <p>
87
* Creates an XML Document object of the specified type with its document
90
* @param namespaceURI The namespace URI of the document
91
* element to create, or null.
92
* @param qualifiedName The qualified name of the document
94
* @param doctype The type of document to be created or null.<p>
96
* When doctype is not null, its
97
* Node.ownerDocument attribute is set to
98
* the document being created.
99
* @return Document A new Document object.
100
* @throws DOMException WRONG_DOCUMENT_ERR: Raised if doctype has
101
* already been used with a different document.
102
* @since WD-DOM-Level-2-19990923
104
public Document createDocument(String namespaceURI,
105
String qualifiedName,
106
DocumentType doctype)
109
if (doctype != null && doctype.getOwnerDocument() != null) {
110
throw new DOMException(DOMException.WRONG_DOCUMENT_ERR,
111
DOMMessageFormatter.formatMessage(
112
DOMMessageFormatter.XML_DOMAIN,
113
"WRONG_DOCUMENT_ERR", null));
115
DocumentImpl doc = new PSVIDocumentImpl(doctype);
116
// If namespaceURI and qualifiedName are null return a Document with no document element.
117
if (qualifiedName != null || namespaceURI != null) {
118
Element e = doc.createElementNS(namespaceURI, qualifiedName);
125
} // class DOMImplementationImpl