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 82 public class CoreDOMImplementationImpl 83 implements DOMImplementation { 84 85 89 91 92 static CoreDOMImplementationImpl singleton = 93 new CoreDOMImplementationImpl(); 94 95 99 114 public boolean hasFeature(String feature, String version) { 115 116 boolean anyVersion = version == null || version.length() == 0; 118 return 119 (feature.equalsIgnoreCase("Core") 120 && (anyVersion 121 || version.equals("1.0") 122 || version.equals("2.0"))) 123 || (feature.equalsIgnoreCase("XML") 124 && (anyVersion 125 || version.equals("1.0") 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 (!CoreDocumentImpl.isXMLName(qualifiedName)) { 155 throw new DOMException (DOMException.INVALID_CHARACTER_ERR, 156 "DOM002 Illegal character"); 157 } 158 int index = qualifiedName.indexOf(':'); 159 int lastIndex = qualifiedName.lastIndexOf(':'); 160 if (index == 0 || index == qualifiedName.length() - 1 || lastIndex!=index) { 162 throw new DOMException (DOMException.NAMESPACE_ERR, 163 "DOM003 Namespace error"); 164 } 165 return new DocumentTypeImpl(null, qualifiedName, publicID, systemID); 166 } 167 187 public Document createDocument(String namespaceURI, 188 String qualifiedName, 189 DocumentType doctype) 190 throws DOMException 191 { 192 if (doctype != null && doctype.getOwnerDocument() != null) { 193 throw new DOMException (DOMException.WRONG_DOCUMENT_ERR, 194 "DOM005 Wrong document"); 195 } 196 CoreDocumentImpl doc = new CoreDocumentImpl(doctype); 197 Element e = doc.createElementNS( namespaceURI, qualifiedName); 198 doc.appendChild(e); 199 return doc; 200 } 201 202 203 206 public Object getFeature(String feature, String version) { 207 return null; 209 } 210 211 } | Popular Tags |