public interface DOMImplementation
DOMImplementation 接口为执行独立于文档对象模型的任何特定实例的操作提供了许多方法。
另请参见 Document Object Model (DOM) Level 3 Core Specification。
| 方法摘要 | |
|---|---|
Document |
createDocument(String namespaceURI, String qualifiedName, DocumentType doctype) 创建具有文档元素的指定类型的 DOM Document 对象。 |
DocumentType |
createDocumentType(String qualifiedName, String publicId, String systemId) 创建空 DocumentType 节点。 |
Object |
getFeature(String feature, String version) 此方法返回一个特定的对象,该对象实现了 DOM Features 中所指定的特定特性或版本的特殊 API。 |
boolean |
hasFeature(String feature, String version) 测试 DOM 实现是否实现在 DOM Features 中指定的特定特性和版本。 |
| 方法详细信息 |
|---|
boolean hasFeature(String feature, String version)
feature - 要测试的特性的名称。
version - 这是要测试的特性的版本号。
true;否则返回
false。
DocumentType createDocumentType(String qualifiedName, String publicId, String systemId) throws DOMException
DocumentType 节点。无法使实体声明和表示法可用。不发生实体引用扩展和默认属性添加。
qualifiedName - 要创建的文档类型的限定名称。
publicId - 外部子集的公共标识符。
systemId - 外部子集的系统标识符。
null 的
Node.ownerDocument 的新
DocumentType 节点。
DOMException - INVALID_CHARACTER_ERR:如果指定的限定名称不是遵循 [
XML 1.0] 的 XML 名称,则引发此异常。
qualifiedName 是错误格式的,则引发此异常。
Document createDocument(String namespaceURI, String qualifiedName, DocumentType doctype) throws DOMException
DocumentType 创建文档,该实现可以实例化特定的
Document 对象,这些对象可支持 "Core" 之外的其他特性,如 "HTML" [
DOM Level 2 HTML]。而在创建文档之后再设置
DocumentType,可能使得此操作很难实现。此外,特定的
Document 创建方法(例如
createHTMLDocument [
DOM Level 2 HTML])可用于获取特定类型的
Document 对象。
namespaceURI - 要创建的文档元素的名称空间 URI 或
null。
qualifiedName - 要创建的文档元素的限定名称或
null。
doctype - 要创建的文档的类型或
null。当
doctype 不是
null 时,其
Node.ownerDocument 属性将被设置为正在创建的文档。
Document 对象。如果
NamespaceURI、
qualifiedName 和
doctype 为
null,则返回的
Document 为空的,不带有文档元素。
DOMException - INVALID_CHARACTER_ERR:如果指定的限定名称不是遵循 [
XML 1.0] 的 XML 名称,则引发此异常。
qualifiedName 是错误格式的;如果
qualifiedName 有前缀且
namespaceURI 为
null;或者如果
qualifiedName 为
null 且
namespaceURI 不同于
null;或者如果
qualifiedName 有名为 "xml" 的前缀且
namespaceURI 不同于 "
http://www.w3.org/XML/1998/namespace" [
XML Namespaces];或者如果 DOM 实现不支持
"XML" 功能但提供非 null 名称空间 URI,因为名称空间由 XML 定义。
doctype 已经用于不同文档或者从不同的实现创建,则引发此异常。
Object getFeature(String feature, String version)
DOMImplementation 接口的特殊对象。
feature - 所请求的功能的名称。注意,追加到功能的名称的任何加号 "+" 将被忽略,因为它在此方法的上下文中无关紧要。
version - 这是要测试的功能的版本号。
null。如果此方法返回的
DOMObject 实现
DOMImplementation 接口,则它必须委托给主要核心实现
DOMImplementation 且不返回与该主要核心
DOMImplementation 不一致的结果,如
hasFeature、
getFeature、等等。