[−][src]Trait xml_dom::Namespaced
An extended interface that provides access to namespace information for elements, including the resolving of prefixes and namespaces in the hierarchy of the document.
The abstraction is of a hash map for each element that maps prefixes to namespace URIs. A
prefix is of type Option<String>
so that the un-prefixed namespace can be represented as
the prefix None
. URIs are simply stored as String
s.
So, given the following XML:
<element
xmlns="example.org/schema/common"
xmlns:p="example.org/schema/product"
xmlns:o="example.org/schema/order">
</element>
we would get the following hash:
{ Some( "o", ): "example.org/schema/order", None: "example.org/schema/common", Some( "p", ): "example.org/schema/product", }
Required methods
fn contains_mapping(&self, prefix: Option<&str>) -> bool
Returns true
if this, and only this, element has a URI mapping for the provided prefix
,
false
otherwise.
fn get_namespace(&self, prefix: Option<&str>) -> Option<String>
Returns the namespace URI associated with the provided prefix
, None
if the prefix is not
mapped to a URI for this, and only this, element.
fn resolve_namespace(&self, prefix: Option<&str>) -> Option<String>
Returns the namespace URI associated with the provided prefix
for this element by looking
up the DOM tree through parent_node
links. Returns None
if the prefix is not mapped to a
URI on this, or any parent, element.
fn contains_mapped_namespace(&self, namespace_uri: &str) -> bool
Returns true
if this, and only this, element has a URI mapping for the provided
namespace_uri
, false
otherwise.
fn get_prefix(&self, namespace_uri: &str) -> Option<Option<String>>
Returns the prefix associated with the provided namespace_uri
, None
if the namespace
URI is not mapped with a prefix for this, and only this, element.
fn resolve_prefix(&self, namespace_uri: &str) -> Option<Option<String>>
Returns the prefix associated with the provided namespace_uri
for this element by looking
up the DOM tree through parent_node
links. Returns None
if the namespace is not mapped
with a prefix for this, or any parent, element.