1 16 17 package org.apache.xerces.dom; 18 19 import org.w3c.dom.DOMException ; 20 import org.w3c.dom.DOMImplementation ; 21 import org.w3c.dom.Document ; 22 import org.w3c.dom.DocumentType ; 23 import org.w3c.dom.Element ; 24 25 26 27 41 public class DOMImplementationImpl extends CoreDOMImplementationImpl 42 implements DOMImplementation { 43 44 48 50 51 static DOMImplementationImpl singleton = new DOMImplementationImpl(); 52 53 54 58 59 public static DOMImplementation getDOMImplementation() { 60 return singleton; 61 } 62 63 67 82 public boolean hasFeature(String feature, String version) { 83 84 boolean result = super.hasFeature(feature, version); 85 if (!result) { 86 boolean anyVersion = version == null || version.length() == 0; 87 if (feature.startsWith("+")) { 88 feature = feature.substring(1); 89 } 90 return ( 91 (feature.equalsIgnoreCase("Events") 92 && (anyVersion || version.equals("2.0"))) 93 || (feature.equalsIgnoreCase("MutationEvents") 94 && (anyVersion || version.equals("2.0"))) 95 || (feature.equalsIgnoreCase("Traversal") 96 && (anyVersion || version.equals("2.0"))) 97 || (feature.equalsIgnoreCase("Range") 98 && (anyVersion || version.equals("2.0"))) 99 || (feature.equalsIgnoreCase("MutationEvents") 100 && (anyVersion || version.equals("2.0")))); 101 } 102 return result; 103 } 105 106 107 127 public Document createDocument(String namespaceURI, 128 String qualifiedName, 129 DocumentType doctype) 130 throws DOMException 131 { 132 if(namespaceURI == null && qualifiedName == null && doctype == null){ 133 return new DocumentImpl(); 136 } 137 else if (doctype != null && doctype.getOwnerDocument() != null) { 138 String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "WRONG_DOCUMENT_ERR", null); 139 throw new DOMException (DOMException.WRONG_DOCUMENT_ERR, msg); 140 } 141 DocumentImpl doc = new DocumentImpl(doctype); 142 Element e = doc.createElementNS( namespaceURI, qualifiedName); 143 doc.appendChild(e); 144 return doc; 145 } 146 147 148 } | Popular Tags |