1 57 58 package org.enhydra.apache.xerces.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 78 public class DOMImplementationImpl 79 implements DOMImplementation { 80 81 85 87 88 static DOMImplementationImpl singleton = new DOMImplementationImpl(); 89 90 94 109 public boolean hasFeature(String feature, String version) { 110 111 boolean anyVersion = version == null || version.length() == 0; 113 return 114 (feature.equalsIgnoreCase("Core") 115 && (anyVersion 116 || version.equals("1.0") 117 || version.equals("2.0"))) 118 || (feature.equalsIgnoreCase("XML") 119 && (anyVersion 120 || version.equals("1.0") 121 || version.equals("2.0"))) 122 || (feature.equalsIgnoreCase("Events") 123 && (anyVersion 124 || version.equals("2.0"))) 125 || (feature.equalsIgnoreCase("MutationEvents") 126 && (anyVersion 127 || version.equals("2.0"))) 128 || (feature.equalsIgnoreCase("Traversal") 129 && (anyVersion 130 || version.equals("2.0"))) 131 ; 132 133 } 135 139 140 public static DOMImplementation getDOMImplementation() { 141 return singleton; 142 } 143 144 154 public DocumentType createDocumentType(String qualifiedName, 155 String publicID, 156 String systemID) 157 { 158 if (!CoreDocumentImpl.isXMLName(qualifiedName)) { 159 throw new DOMException (DOMException.INVALID_CHARACTER_ERR, 160 "DOM002 Illegal character"); 161 } 162 int index = qualifiedName.indexOf(':'); 163 int lastIndex = qualifiedName.lastIndexOf(':'); 164 if (index == 0 || index == qualifiedName.length() - 1 || lastIndex!=index) { 166 throw new DOMException (DOMException.NAMESPACE_ERR, 167 "DOM003 Namespace error"); 168 } 169 return new DocumentTypeImpl(null, qualifiedName, publicID, systemID); 170 } 171 191 public Document createDocument(String namespaceURI, 192 String qualifiedName, 193 DocumentType doctype) 194 throws DOMException 195 { 196 if (doctype != null && doctype.getOwnerDocument() != null) { 197 throw new DOMException (DOMException.WRONG_DOCUMENT_ERR, 198 "DOM005 Wrong document"); 199 } 200 DocumentImpl doc = new DocumentImpl(doctype); 201 Element e = doc.createElementNS( namespaceURI, qualifiedName); 202 doc.appendChild(e); 203 return doc; 204 } 205 206 207 210 public Object getFeature(String feature, String version) { 211 return null; 213 } 214 215 } | Popular Tags |