1 57 58 package org.xquark.xpath.datamodel.xerces.dom; 59 60 import org.w3c.dom.*; 61 62 74 public class DOMImplementationImpl 75 implements DOMImplementation { 76 77 81 83 84 static DOMImplementationImpl singleton = new DOMImplementationImpl(); 85 86 90 105 public boolean hasFeature(String feature, String version) { 106 107 boolean anyVersion = version == null || version.length() == 0; 109 return 110 (feature.equalsIgnoreCase("Core") 111 && (anyVersion 112 || version.equals("1.0") 113 || version.equals("2.0"))) 114 || (feature.equalsIgnoreCase("XML") 115 && (anyVersion 116 || version.equals("1.0") 117 || version.equals("2.0"))) 118 || (feature.equalsIgnoreCase("Events") 119 && (anyVersion 120 || version.equals("2.0"))) 121 || (feature.equalsIgnoreCase("MutationEvents") 122 && (anyVersion 123 || version.equals("2.0"))) 124 || (feature.equalsIgnoreCase("Traversal") 125 && (anyVersion 126 || version.equals("2.0"))) 127 ; 128 129 } 131 135 136 public static DOMImplementation getDOMImplementation() { 137 return singleton; 138 } 139 140 150 public DocumentType createDocumentType(String qualifiedName, 151 String publicID, 152 String systemID) 153 { 154 if (!DocumentImpl.isXMLName(qualifiedName)) { 155 throw new DOMException(DOMException.INVALID_CHARACTER_ERR, 156 "DOM002 Illegal character"); 157 } 158 int index = qualifiedName.indexOf(':'); 159 if (index == 0 || index == qualifiedName.length() - 1) { 160 throw new DOMException(DOMException.NAMESPACE_ERR, 161 "DOM003 Namespace error"); 162 } 163 return new DocumentTypeImpl(null, qualifiedName, publicID, systemID); 164 } 165 185 public Document createDocument(String namespaceURI, 186 String qualifiedName, 187 DocumentType doctype) 188 throws DOMException 189 { 190 if (doctype != null && doctype.getOwnerDocument() != null) { 191 throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, 192 "DOM005 Wrong document"); 193 } 194 DocumentImpl doc = new DocumentImpl(doctype); 195 Element e = doc.createElementNS( namespaceURI, qualifiedName); 196 doc.appendChild(e); 197 return doc; 198 } 199 200 } | Popular Tags |