Trait xml_dom::level2::Document [−][src]
This corresponds to the DOM Document
interface.
Required methods
fn doc_type(&self) -> Option<Self::NodeRef>
[src]
The Document Type Declaration (see DocumentType
) associated with
this document.
Specification
For HTML documents as well as XML documents without a document type
declaration this returns null
. The DOM Level 2 does not support editing the Document Type
Declaration. docType
cannot be altered in any way, including through the use of methods
inherited from the Node
interface, such as insertNode
or removeNode
.
fn document_element(&self) -> Option<Self::NodeRef>
[src]
This is a convenience attribute that allows direct access to the child node that is the root element of the document.
Specification
For HTML documents, this is the element with the tagName "HTML"
.
fn implementation(&self) -> &dyn DOMImplementation<NodeRef = Self::NodeRef>
[src]
The DOMImplementation object that handles this document.
Note: this function will panic if for some reason an implementation is not associated with the document instance.
Specification
A DOM application may use objects from multiple implementations.
fn create_attribute(&self, name: &str) -> Result<Self::NodeRef>
[src]
Creates an Attribute
of the given name. Note that the Attr
instance can then be set on an Element
using the setAttributeNode
method.
Specification
To create an attribute with a qualified name and namespace URI, use the createAttributeNS
method.
Parameters
name
of typeDOMString
: The name of the attribute.
Return Value
Attr
: A newAttr
object with thenodeName
attribute set to name, andlocalName
,prefix
, andnamespaceURI
set tonull
. The value of the attribute is the empty string.
Exceptions
INVALID_CHARACTER_ERR
: Raised if the specified name contains an illegal character.
fn create_attribute_with(
&self,
name: &str,
value: &str
) -> Result<Self::NodeRef>
[src]
&self,
name: &str,
value: &str
) -> Result<Self::NodeRef>
Implementation defined extension: this is the same as create_attribute
except that it
also sets the attribute value.
fn create_attribute_ns(
&self,
namespace_uri: &str,
qualified_name: &str
) -> Result<Self::NodeRef>
[src]
&self,
namespace_uri: &str,
qualified_name: &str
) -> Result<Self::NodeRef>
Creates an attribute of the given qualified name and namespace URI.
Specification
HTML-only DOM implementations do not need to implement this method.
Parameters
namespaceURI
of typeDOMString
: The namespace URI of the attribute to create.qualifiedName
of typeDOMString
: The qualified name of the attribute to instantiate.
Return Value
Attr
: A newAttr
object with the following attributes:
Attribute | Value |
---|---|
Node.nodeName | qualifiedName |
Node.namespaceURI | namespaceURI |
Node.prefix | prefix, extracted from qualifiedName , or null if there is no prefix |
Node.localName | local name, extracted from qualifiedName |
Attr.name | qualifiedName |
Node.nodeValue | the empty string |
Exceptions
INVALID_CHARACTER_ERR
: Raised if the specified qualified name contains an illegal character.NAMESPACE_ERR
: Raised if thequalifiedName
is malformed, if thequalifiedName
has aprefix
and thenamespaceURI
isnull
, if thequalifiedName
has aprefix
that is “xml” and thenamespaceURI
is different from “http://www.w3.org/XML/1998/namespace”, or if thequalifiedName
is “xmlns” and the namespaceURI is different from “http://www.w3.org/2000/xmlns/”.
fn create_cdata_section(&self, data: &str) -> Result<Self::NodeRef>
[src]
Creates a CDataSection
node whose value is the specified string.
Specification
Parameters
data
of typeDOMString
: The data for theCDATASection
contents.
Return Value
CDATASection
: The newCDATASection
object.
Exceptions
NOT_SUPPORTED_ERR
: Raised if this document is an HTML document.
fn create_document_fragment(&self) -> Result<Self::NodeRef>
[src]
Creates an empty DocumentFragment object.
Specification
Return Value
DocumentFragment
: A new DocumentFragment
.
fn create_entity_reference(&self, name: &str) -> Result<Self::NodeRef>
[src]
Creates an EntityReference
object.
Specification
In addition, if the referenced entity is known, the child list of the EntityReference
node is made the same as that of the corresponding Entity
node.
Note: If any descendant of the Entity
node has an unbound namespace prefix, the
corresponding descendant of the created EntityReference
node is also unbound; (its
namespaceURI
is null
). The DOM Level 2 does not support any mechanism to resolve
namespace prefixes.
Parameters
name
of typeDOMString
: The name of the entity to reference.
Return Value
EntityReference
: The newEntityReference
object.
Exceptions
INVALID_CHARACTER_ERR
: Raised if the specified name contains an illegal character.NOT_SUPPORTED_ERR
: Raised if this document is an HTML document.
fn create_comment(&self, data: &str) -> Self::NodeRef
[src]
Creates a Comment
node given the specified string.
Specification
Parameters
data
of typeDOMString
: The data for the node.
Return Value
Comment
: The newComment
object.
fn create_element(&self, tag_name: &str) -> Result<Self::NodeRef>
[src]
Creates an element of the type specified.
Specification
Note that the instance returned implements the Element
interface, so
attributes can be specified directly on the returned object.
In addition, if there are known attributes with default values, Attr
nodes representing them are automatically created and attached to the element.
To create an element with a qualified name and namespace URI, use the createElementNS
method.
Parameters
tagName
of typeDOMString: The name of the element type to instantiate. For XML, this is case-sensitive. For HTML, the
tagName` parameter may be provided in any case, but it must be mapped to the canonical uppercase form by the DOM implementation.
Return Value
Element
: A newElement
object with thenodeName
attribute set totagName
, andlocalName
,prefix
, andnamespaceURI
set tonull
.
Exceptions
INVALID_CHARACTER_ERR
: Raised if the specified name contains an illegal character.
fn create_element_ns(
&self,
namespace_uri: &str,
qualified_name: &str
) -> Result<Self::NodeRef>
[src]
&self,
namespace_uri: &str,
qualified_name: &str
) -> Result<Self::NodeRef>
Creates an element of the given qualified name and namespace URI.
Specification
HTML-only DOM implementations do not need to implement this method.
Parameters
namespaceURI
of typeDOMString
: The namespace URI of the attribute to create.qualifiedName
of typeDOMString
: The qualified name of the attribute to instantiate.
Return Value
Element
: A new Element object with the following attributes:
Attribute | Value |
---|---|
Node.nodeName | qualifiedName |
Node.namespaceURI | namespaceURI |
Node.prefix | prefix, extracted from qualifiedName , or null if there is no prefix |
Node.localName | local name, extracted from qualifiedName |
Attr.name | qualifiedName |
Node.nodeValue | the empty string |
Exceptions
INVALID_CHARACTER_ERR
: Raised if the specified qualified name contains an illegal character.NAMESPACE_ERR
: Raised if thequalifiedName
is malformed, if thequalifiedName
has aprefix
and thenamespaceURI
isnull
, if thequalifiedName
has aprefix
that is “xml” and thenamespaceURI
is different from “http://www.w3.org/XML/1998/namespace”, or if thequalifiedName
is “xmlns” and the namespaceURI is different from “http://www.w3.org/2000/xmlns/”.
fn create_processing_instruction(
&self,
target: &str,
data: Option<&str>
) -> Result<Self::NodeRef>
[src]
&self,
target: &str,
data: Option<&str>
) -> Result<Self::NodeRef>
Creates a ProcessingInstruction
node given the
specified name and data strings.
Specification
Parameters
target
of typeDOMString
: The target part of the processing instruction.data
of typeDOMString
: Thedata
for thenode
.
Return Value
ProcessingInstruction
: The newProcessingInstruction
object.
Exceptions
INVALID_CHARACTER_ERR
: Raised if the specified target contains an illegal character.NOT_SUPPORTED_ERR
: Raised if this document is an HTML document.
fn create_text_node(&self, data: &str) -> Self::NodeRef
[src]
Creates a Text
node given the specified string.
Specification
Parameters
data
of typeDOMString
: The data for the node.
Return Value
Text
: The new Text object.
fn get_element_by_id(&self, id: &str) -> Option<Self::NodeRef>
[src]
Returns the Element
whose ID is given by elementId
.
Note: This implementation will ensure that attributes named xml:id
or id
with the
XML namespace will be treated as identifiers. If the
ProcessingOptions::set_assume_ids
method is used when constructing a document any attribute with the local name id
will
be treated as identifiers.
Specification
If no such element exists, returns null
. Behavior is not defined if more than one element
has this ID.
Note: The DOM implementation must have information that says which attributes are of type
ID. Attributes with the name “ID” are not of type ID unless so defined. Implementations
that do not know whether attributes are of type ID or not are expected to return null
.
Parameters
elementId
of typeDOMString
: The unique id value for an element.
Return Value
Element
: The matching element.
fn get_elements_by_tag_name(&self, tag_name: &str) -> Vec<Self::NodeRef>
[src]
Returns a NodeList
of all the Element
s with a given tag name in the
order in which they are encountered in a preorder traversal of the Document tree.
Note: This method will panic if document_element
is not an Element
node.
Specification
Parameters
tagname
of typeDOMString
: The name of the tag to match on. The special value “*” matches all tags.
Return Value
NodeList
: A newNodeList
object containing all the matchedElement
s.
fn get_elements_by_tag_name_ns(
&self,
namespace_uri: &str,
local_name: &str
) -> Vec<Self::NodeRef>
[src]
&self,
namespace_uri: &str,
local_name: &str
) -> Vec<Self::NodeRef>
Returns a NodeList
of all the Element
s with a given local name and
namespace URI in the order in which they are encountered in a preorder traversal of the
Document tree.
Note: This method will panic if document_element
is not an Element
node.
Specification
Parameters
namespaceURI
of typeDOMString
: The namespace URI of the elements to match on. The special value “*” matches all namespaces.localName
of typeDOMString
: The local name of the elements to match on. The special value “*” matches all local names.
Return Value
NodeList
: A newNodeList
object containing all the matchedElement
s.
Implementors
impl Document for RefNode
[src]
fn doc_type(&self) -> Option<RefNode>
[src]
fn document_element(&self) -> Option<RefNode>
[src]
fn implementation(&self) -> &dyn DOMImplementation<NodeRef = RefNode>
[src]
fn create_attribute(&self, name: &str) -> Result<RefNode>
[src]
fn create_attribute_with(&self, name: &str, value: &str) -> Result<RefNode>
[src]
fn create_attribute_ns(
&self,
namespace_uri: &str,
qualified_name: &str
) -> Result<RefNode>
[src]
&self,
namespace_uri: &str,
qualified_name: &str
) -> Result<RefNode>
fn create_cdata_section(&self, data: &str) -> Result<RefNode>
[src]
fn create_document_fragment(&self) -> Result<RefNode>
[src]
fn create_entity_reference(&self, name: &str) -> Result<RefNode>
[src]
fn create_comment(&self, data: &str) -> RefNode
[src]
fn create_element(&self, tag_name: &str) -> Result<RefNode>
[src]
fn create_element_ns(
&self,
namespace_uri: &str,
qualified_name: &str
) -> Result<RefNode>
[src]
&self,
namespace_uri: &str,
qualified_name: &str
) -> Result<RefNode>
fn create_processing_instruction(
&self,
target: &str,
data: Option<&str>
) -> Result<RefNode>
[src]
&self,
target: &str,
data: Option<&str>
) -> Result<RefNode>
fn create_text_node(&self, data: &str) -> RefNode
[src]
fn get_element_by_id(&self, id: &str) -> Option<RefNode>
[src]
fn get_elements_by_tag_name(&self, tag_name: &str) -> Vec<RefNode>
[src]
fn get_elements_by_tag_name_ns(
&self,
namespace_uri: &str,
local_name: &str
) -> Vec<RefNode>
[src]
&self,
namespace_uri: &str,
local_name: &str
) -> Vec<RefNode>