Expand description

Implementation for DOM Core Level 2.

Interface Mapping

IDL InterfaceRust Mapping
AttrAttribute
CharacterDataCharacterData
CDATASectionCDataSection
CommentComment
DocumentDocument
DocumentFragmentDocumentFragment
DocumentTypeDocumentType
DOMImplementationDOMImplementation
ElementElement
EntityEntity
EntityReferenceEntityReference
NamedNodeMapHashMap<Name, RefNode>
NodeNode
NodeListVec<Rc<RefNode>>
NotationNotation
ProcessingInstructionProcessingInstruction
TextText

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.

  1. The get_implementation function returns an instance of DOMImplementation 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.”.
  2. The get_implementation_version function in the dom_impl module returns a vendor-specific version identifier for the DOMImplementation.
  3. The standard DOMImplementation trait also has an additional member create_document_with_options, and associated ProcessingOptions structure, that can set optional behavior for a given Document instance.
  4. The trait DocumentDecl extends Document with the ability to set and retrieve the XML declaration from the document’s prolog.
  5. The trait Namespaced extends Element with the ability to look-up namespace mappings (using the standard xmlns attribute).
  6. The functions create_entity, create_internal_entity, and create_notation in the dom_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.

Type Definitions

Opaque DOM tree node reference. This is the type used by this implementation as the concrete type for the NodeRef associated type in the Node trait.

This standard Result structure is used wherever an IDL function is marked as throwing exceptions.