Documents

Struct Documents 

Source
pub struct Documents { /* private fields */ }
Expand description

A collection of XML documents as can be used by XPath and XSLT.

This collection can be prepared before any XPath or XSLT processing begins.

Alternatively this collection can be added to incrementally during processing using the fn:doc function for instance. Once a document under a URL is present, it cannot be changed anymore.

The fn:parse-xml and fn:parse-xml-fragment functions can be used to create new documents from strings without URLs.

Implementations§

Source§

impl Documents

Source

pub fn new() -> Documents

Create a new empty collection of documents.

Source

pub fn cleanup(&mut self, xot: &mut Xot)

Clean up all documents.

Source

pub fn add_string( &mut self, xot: &mut Xot, uri: Option<&RiStr<IriSpec>>, xml: &str, ) -> Result<DocumentHandle, DocumentsError>

Add a string as an XML document. It can be designated with a URI.

Source

pub fn add_fragment_string( &mut self, xot: &mut Xot, xml: &str, ) -> Result<DocumentHandle, DocumentsError>

Add a string as an XML fragment.

Source

pub fn add_root( &mut self, uri: Option<&RiStr<IriSpec>>, root: Node, ) -> Result<DocumentHandle, DocumentsError>

Add a root node of an XML document. Designate it with a URI.

Source

pub fn get_by_handle(&self, handle: DocumentHandle) -> Option<&Document>

Obtain a document by handle

Source

pub fn get_node_by_handle(&self, handle: DocumentHandle) -> Option<Node>

Obtain document node by handle

Source

pub fn get_by_uri(&self, uri: &RiStr<IriSpec>) -> Option<&Document>

Obtain a document by URI

It’s only possible to obtain a document by URI if it was added with a URI.

Source

pub fn get_node_by_uri(&self, uri: &RiStr<IriSpec>) -> Option<Node>

Obtain document node by URI

Source

pub fn get_uri_by_document_node(&self, node: Node) -> Option<RiString<IriSpec>>

Obtain document URI by document node.

This only returns a URI if the document was added with a URI.

Source

pub fn len(&self) -> usize

How many documents are stored.

Source

pub fn is_empty(&self) -> bool

Is the collection empty?

Trait Implementations§

Source§

impl Clone for Documents

Source§

fn clone(&self) -> Documents

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Documents

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for Documents

Source§

fn default() -> Documents

Returns the “default value” for a type. Read more
Source§

impl From<Documents> for DocumentsRef

Source§

fn from(documents: Documents) -> DocumentsRef

Converts to this type from the input type.

Auto Trait Implementations§

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<'src, T> IntoMaybe<'src, T> for T
where T: 'src,

Source§

type Proj<U: 'src> = U

Source§

fn map_maybe<R>( self, _f: impl FnOnce(&'src T) -> &'src R, g: impl FnOnce(T) -> R, ) -> <T as IntoMaybe<'src, T>>::Proj<R>
where R: 'src,

Source§

impl<'p, T> Seq<'p, T> for T
where T: Clone,

Source§

type Item<'a> = &'a T where T: 'a

The item yielded by the iterator.
Source§

type Iter<'a> = Once<&'a T> where T: 'a

An iterator over the items within this container, by reference.
Source§

fn seq_iter(&self) -> <T as Seq<'p, T>>::Iter<'_>

Iterate over the elements of the container.
Source§

fn contains(&self, val: &T) -> bool
where T: PartialEq,

Check whether an item is contained within this sequence.
Source§

fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>
where 'p: 'b,

Convert an item of the sequence into a MaybeRef.
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T

Source§

impl<T> OrderedSeq<'_, T> for T
where T: Clone,