Expand description
Implementation for DOM Core Level 2.
Interface Mapping
IDL Interface | Rust Mapping |
---|---|
Attr | Attribute |
CharacterData | CharacterData |
CDATASection | CDataSection |
Comment | Comment |
Document | Document |
DocumentFragment | DocumentFragment |
DocumentType | DocumentType |
DOMImplementation | DOMImplementation |
Element | Element |
Entity | Entity |
EntityReference | EntityReference |
NamedNodeMap | HashMap<Name, RefNode> |
Node | Node |
NodeList | Vec<Rc<RefNode>> |
Notation | Notation |
ProcessingInstruction | ProcessingInstruction |
Text | Text |
Conformance
The has_feature
method on DOMImplementation
and is_supported
on
Node
will return true when the request is for support of the Core or XML
feature and supports both version 1.0 and version 2.0 of Core and version 1.0 of XML.
use xml_dom::level2::{DOMImplementation, get_implementation};
let implementation = get_implementation();
assert!(implementation.has_feature("Core", "1.0"));
assert!(implementation.has_feature("Core", "2.0"));
assert!(implementation.has_feature("XML", "1.0"));
assert!(implementation.has_feature("XML", "2.0"));
Extensions
The following extensions are provided beyond the DOM Level 2 specification, all extensions are in the
level2::ext
module.
- The
get_implementation
function returns an instance ofDOMImplementation
to allow bootstrapping the creation of documents. This satisfies the requirement from the specification: “The DOM Level 2 API does not define a standard way to create DOMImplementation objects; DOM implementations must provide some proprietary way of bootstrapping these DOM interfaces, and then all other objects can be built from there.”. - The
get_implementation_version
function in thedom_impl
module returns a vendor-specific version identifier for theDOMImplementation
. - The standard
DOMImplementation
trait also has an additional membercreate_document_with_options
, and associatedProcessingOptions
structure, that can set optional behavior for a givenDocument
instance. - The trait
DocumentDecl
extendsDocument
with the ability to set and retrieve the XML declaration from the document’s prolog. - The trait
Namespaced
extendsElement
with the ability to look-up namespace mappings (using the standardxmlns
attribute). - The functions
create_entity
,create_internal_entity
, andcreate_notation
in thedom_impl
module provide the ability to create instances of these Level 2 extended interfaces. In general most clients using the DOM do not need to create these however parsers constructing the DOM may.
Re-exports
pub use dom_impl::get_implementation;
Modules
Provides safe RefNode
conversion functions.
This module implements certain capabilities required by, but not specified by, the DOM Core.
This module contains extensions above and beyond the Level 2 specification.
Structs
Corresponds to attributes localName
, namespaceURI
, and prefix
on the DOM Node
interface.
Enums
Corresponds to the DOM DomException
type.
This corresponds to the DOM NodeType
set of constants.
Traits
This corresponds to the DOM Attr
interface.
This corresponds to the DOM CDataSection
interface.
This corresponds to the DOM CharacterData
interface.
This corresponds to the DOM Comment
interface.
This corresponds to the DOM DOMImplementation
interface.
This corresponds to the DOM Document
interface.
This corresponds to the DOM DocumentFragment
interface (current unsupported).
This corresponds to the DOM DocumentType
interface.
This corresponds to the DOM Element
interface.
This corresponds to the DOM Entity
interface.
This corresponds to the DOM EntityReference
interface.
This corresponds to the DOM Node
interface.
This corresponds to the DOM Notation
interface.
This corresponds to the DOM ProcessingInstruction
interface.
This corresponds to the DOM Text
interface.