01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
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.
16: */
17:
18: package org.apache.wml.dom;
19:
20: import org.apache.wml.WMLDOMImplementation;
21: import org.apache.xerces.dom.DOMImplementationImpl;
22: import org.apache.xerces.dom.DOMMessageFormatter;
23: import org.apache.xerces.dom.DocumentImpl;
24: import org.w3c.dom.DOMException;
25: import org.w3c.dom.DOMImplementation;
26: import org.w3c.dom.Document;
27: import org.w3c.dom.DocumentType;
28: import org.w3c.dom.Element;
29:
30: /**
31: * @xerces.internal
32: * @version $Id: WMLDOMImplementationImpl.java 516291 2007-03-09 04:26:22Z mrglavas $
33: * @author <a href="mailto:david@topware.com.tw">David Li</a>
34: */
35: public class WMLDOMImplementationImpl extends DOMImplementationImpl
36: implements WMLDOMImplementation {
37:
38: static final DOMImplementationImpl singleton = new WMLDOMImplementationImpl();
39:
40: /** NON-DOM: Obtain and return the single shared object */
41: public static DOMImplementation getDOMImplementation() {
42: return singleton;
43: }
44:
45: /**
46: * @see org.w3c.dom.DOMImplementation
47: */
48: public Document createDocument(String namespaceURI,
49: String qualifiedName, DocumentType doctype)
50: throws DOMException {
51: if (doctype != null && doctype.getOwnerDocument() != null) {
52: throw new DOMException(DOMException.WRONG_DOCUMENT_ERR,
53: DOMMessageFormatter.formatMessage(
54: DOMMessageFormatter.XML_DOMAIN,
55: "WRONG_DOCUMENT_ERR", null));
56: }
57: DocumentImpl doc = new WMLDocumentImpl(doctype);
58: // If namespaceURI and qualifiedName are null return a Document with no document element.
59: if (qualifiedName != null || namespaceURI != null) {
60: Element e = doc
61: .createElementNS(namespaceURI, qualifiedName);
62: doc.appendChild(e);
63: }
64: return doc;
65: }
66: }
|