[][src]Trait xml_dom::level2::ext::Namespaced

pub trait Namespaced: Element {
    fn contains_mapping(&self, prefix: Option<&str>) -> bool;
fn get_namespace(&self, prefix: Option<&str>) -> Option<String>;
fn resolve_namespace(&self, prefix: Option<&str>) -> Option<String>;
fn contains_mapped_namespace(&self, namespace_uri: &str) -> bool;
fn get_prefix(&self, namespace_uri: &str) -> NamespacePrefix;
fn resolve_prefix(&self, namespace_uri: &str) -> NamespacePrefix; }

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 Strings.

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:

This example is not tested
{
    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) -> NamespacePrefix

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) -> NamespacePrefix

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.

Loading content...

Implementors

impl Namespaced for RefNode[src]

Loading content...