1 57 58 package com.sun.org.apache.xerces.internal.dom; 59 60 import org.w3c.dom.DOMException ; 61 import org.w3c.dom.DOMImplementation ; 62 import org.w3c.dom.Document ; 63 import org.w3c.dom.DocumentType ; 64 import org.w3c.dom.Element ; 65 66 67 68 80 public class DOMImplementationImpl extends CoreDOMImplementationImpl 81 implements DOMImplementation { 82 83 87 89 90 static DOMImplementationImpl singleton = new DOMImplementationImpl(); 91 92 93 97 98 public static DOMImplementation getDOMImplementation() { 99 return singleton; 100 } 101 102 106 121 public boolean hasFeature(String feature, String version) { 122 123 boolean result = super.hasFeature(feature, version); 124 if (!result) { 125 boolean anyVersion = version == null || version.length() == 0; 126 if (feature.startsWith("+")) { 127 feature = feature.substring(1); 128 } 129 return ( 130 (feature.equalsIgnoreCase("Events") 131 && (anyVersion || version.equals("2.0"))) 132 || (feature.equalsIgnoreCase("MutationEvents") 133 && (anyVersion || version.equals("2.0"))) 134 || (feature.equalsIgnoreCase("Traversal") 135 && (anyVersion || version.equals("2.0"))) 136 || (feature.equalsIgnoreCase("Range") 137 && (anyVersion || version.equals("2.0"))) 138 || (feature.equalsIgnoreCase("MutationEvents") 139 && (anyVersion || version.equals("2.0")))); 140 } 141 return result; 142 } 144 145 146 166 public Document createDocument(String namespaceURI, 167 String qualifiedName, 168 DocumentType doctype) 169 throws DOMException 170 { 171 if(namespaceURI == null && qualifiedName == null && doctype == null){ 172 return new DocumentImpl(); 175 } 176 else if (doctype != null && doctype.getOwnerDocument() != null) { 177 String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "WRONG_DOCUMENT_ERR", null); 178 throw new DOMException (DOMException.WRONG_DOCUMENT_ERR, msg); 179 } 180 DocumentImpl doc = new DocumentImpl(doctype); 181 Element e = doc.createElementNS( namespaceURI, qualifiedName); 182 doc.appendChild(e); 183 return doc; 184 } 185 186 187 } | Popular Tags |