public interface DOMImplementation
org.w3c.dom.DOMImplementation |
DOMImplementation
接口提供了许多用于执行独立于文档对象模型的任何特定实例的操作的方法。
另见 Document Object Model (DOM) Level 3 Core Specification 。
Public methods |
|
---|---|
abstract Document |
createDocument(String namespaceURI, String qualifiedName, DocumentType doctype) 使用其文档元素创建指定类型的DOM Document对象。 |
abstract DocumentType |
createDocumentType(String qualifiedName, String publicId, String systemId) 创建一个空的 |
abstract Object |
getFeature(String feature, String version) 此方法返回一个专用对象,该对象实现指定功能和版本的专用API,如中指定。 |
abstract boolean |
hasFeature(String feature, String version) 测试DOM实现是否实现了特定的功能和版本,如中所述。 |
Document createDocument (String namespaceURI, String qualifiedName, DocumentType doctype)
使用其文档元素创建指定类型的DOM Document对象。
请注意,根据为创建文档给出的DocumentType
,实现可能会实例化支持比“Core”更多特性的专用Document
对象,如“HTML”[ DOM Level 2 HTML ]。 另一方面,在文档创建后设置DocumentType
使得这种情况不太可能发生。 备选地,专业Document
创建方法,例如createHTMLDocument
[ DOM Level 2 HTML ],可以被用于获得特定类型的Document
对象。
Parameters | |
---|---|
namespaceURI |
String : The namespace URI of the document element to create or null . |
qualifiedName |
String : The qualified name of the document element to be created or null . |
doctype |
DocumentType : The type of document to be created or null . When doctype is not null , its Node.ownerDocument attribute is set to the document being created. |
Returns | |
---|---|
Document |
A new Document object with its document element. If the NamespaceURI , qualifiedName , and doctype are null , the returned Document is empty with no document element. |
Throws | |
---|---|
DOMException |
INVALID_CHARACTER_ERR: Raised if the specified qualified name is not an XML name according to [XML 1.0]. NAMESPACE_ERR: Raised if the qualifiedName is malformed, if the qualifiedName has a prefix and the namespaceURI is null , or if the qualifiedName is null and the namespaceURI is different from null , or if the qualifiedName has a prefix that is "xml" and the namespaceURI is different from " http://www.w3.org/XML/1998/namespace" [XML Namespaces] , or if the DOM implementation does not support the "XML" feature but a non-null namespace URI was provided, since namespaces were defined by XML. WRONG_DOCUMENT_ERR: Raised if doctype has already been used with a different document or was created from a different implementation. NOT_SUPPORTED_ERR: May be raised if the implementation does not support the feature "XML" and the language exposed through the Document does not support XML Namespaces (such as [HTML 4.01]). |
DocumentType createDocumentType (String qualifiedName, String publicId, String systemId)
创建一个空的DocumentType
节点。 实体声明和符号不可用。 不会发生实体引用扩展和默认属性添加。
Parameters | |
---|---|
qualifiedName |
String : The qualified name of the document type to be created. |
publicId |
String : The external subset public identifier. |
systemId |
String : The external subset system identifier. |
Returns | |
---|---|
DocumentType |
A new DocumentType node with Node.ownerDocument set to null . |
Throws | |
---|---|
DOMException |
INVALID_CHARACTER_ERR: Raised if the specified qualified name is not an XML name according to [XML 1.0]. NAMESPACE_ERR: Raised if the qualifiedName is malformed. NOT_SUPPORTED_ERR: May be raised if the implementation does not support the feature "XML" and the language exposed through the Document does not support XML Namespaces (such as [HTML 4.01]). |
Object getFeature (String feature, String version)
此方法返回一个专用对象,该对象实现指定功能和版本的专用API,如中指定。 专用对象也可以通过使用特定于绑定的投射方法来获得,但不一定如所讨论的那样。 此方法还允许实现提供不支持DOMImplementation
接口的专用对象。
Parameters | |
---|---|
feature |
String : The name of the feature requested. Note that any plus sign "+" prepended to the name of the feature will be ignored since it is not significant in the context of this method. |
version |
String : This is the version number of the feature to test. |
Returns | |
---|---|
Object |
Returns an object which implements the specialized APIs of the specified feature and version, if any, or null if there is no object which implements interfaces associated with that feature. If the DOMObject returned by this method implements the DOMImplementation interface, it must delegate to the primary core DOMImplementation and not return results inconsistent with the primary core DOMImplementation such as hasFeature , getFeature , etc. |
boolean hasFeature (String feature, String version)
测试DOM实现是否实现了特定的功能和版本,如中所述。
Parameters | |
---|---|
feature |
String : The name of the feature to test. |
version |
String : This is the version number of the feature to test. |
Returns | |
---|---|
boolean |
true if the feature is implemented in the specified version, false otherwise. |