Skip to main content

XmlTree

Struct XmlTree 

Source
pub struct XmlTree<'a> { /* private fields */ }
Expand description

An XML document built into a parsec-web tree: its elements are Ns::Xml with their names as written, its attributes’ namespaces are AttrNs::Host ids, and names holds what those ids stand for. The host keeps namespace declarations out of the attributes.

Implementations§

Source§

impl<'a> XmlTree<'a>

Source

pub fn new(tree: &'a Document, names: &'a dyn Namespaces) -> XmlTree<'a>

Trait Implementations§

Source§

impl<'a> Clone for XmlTree<'a>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for XmlTree<'a>

Source§

impl Tree for XmlTree<'_>

Source§

fn len(&self) -> usize

How many node ids there are, including those of removed nodes.
Source§

fn kind(&self, n: NodeId) -> NodeType

Source§

fn parent(&self, n: NodeId) -> Option<NodeId>

Source§

fn first_child(&self, n: NodeId) -> Option<NodeId>

Source§

fn next_sibling(&self, n: NodeId) -> Option<NodeId>

Source§

fn prev_sibling(&self, n: NodeId) -> Option<NodeId>

Source§

fn qualified_name(&self, n: NodeId) -> &str

An element’s name as written, with any prefix: what name() gives. Lowercase in HTML.
Source§

fn local_name(&self, n: NodeId) -> &str

An element’s name without its prefix: what local-name() gives.
Source§

fn namespace_uri(&self, n: NodeId) -> &str

An element’s namespace URI; “” for no namespace.
Source§

fn tag_key(&self, n: NodeId) -> TagKey<'_>

What crate::Index keys an element’s name tests on.
Source§

fn attribute_count(&self, n: NodeId) -> u32

How many attributes an element has. In XPath’s data model, xmlns and xmlns:* are namespace nodes rather than attributes, so an XML tree leaves them out of these. An HTML tree keeps them, as libxml2’s HTML parser does.
Source§

fn attribute(&self, n: NodeId, i: u32) -> Option<Attr<'_>>

An element’s ith attribute, in document order. A query reads attributes by place, so this should take constant time.
Source§

fn namespace_declaration_count(&self, n: NodeId) -> u32

How many namespaces node n declares: an XML element’s xmlns and xmlns:* attributes. A root that isn’t an element may declare the namespaces in scope where its tree was cut from, which its elements then inherit. The namespace axis works out what’s in scope from these. None by default, as an HTML tree has none: its elements have only the xml namespace, which is always in scope.
Source§

fn namespace_declaration(&self, n: NodeId, i: u32) -> Option<(&str, &str)>

Node n’s ith declaration, in the order written: the prefix (“” for the default namespace) and the URI (“” for xmlns="", which takes the binding away). Of two for one prefix on a node, the first counts. This should take constant time.
Source§

fn data(&self, n: NodeId) -> &str

A text, CDATA section, comment or processing instruction’s text.
Source§

fn pi_target(&self, n: NodeId) -> Option<&str>

A processing instruction’s target.
Source§

fn is_xml(&self) -> bool

Whether names compare exactly (XML), rather than ignoring ASCII case with prefixes left as part of the name (HTML).
Source§

fn id(&self, n: NodeId) -> Option<&str>

The value id() finds an element by: HTML’s id, or XML’s xml:id or an attribute the DTD declares an ID.
Source§

fn lang(&self, n: NodeId) -> Option<&str>

The language an element declares, if it declares one, for lang(): xml:lang, or HTML’s lang.
Source§

fn is_empty(&self) -> bool

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for XmlTree<'a>

§

impl<'a> !UnwindSafe for XmlTree<'a>

§

impl<'a> Forget for XmlTree<'a>

§

impl<'a> Freeze for XmlTree<'a>

§

impl<'a> Move for XmlTree<'a>

§

impl<'a> Send for XmlTree<'a>

§

impl<'a> Sync for XmlTree<'a>

§

impl<'a> Unpin for XmlTree<'a>

§

impl<'a> UnsafeUnpin for XmlTree<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.