Skip to main content

Executable

Struct Executable 

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

A stylesheet ready to run: prepared once, run on any number of documents with Executable::transform.

Implementations§

Source§

impl Executable

Source

pub fn new(sheet: &Stylesheet) -> Result<Self, PrepareErrors>

Prepares a loaded stylesheet.

§Errors

Every problem found: XPath expressions that do not compile in their static context (unknown variables or functions), calls of undeclared templates, and the constructs refused because their result would differ from the reference engine’s (instructions that construct nodes inside an xsl:function or a variable with as, a positional predicate in a parenthesized pattern, system-property() with a prefixed name).

Source

pub fn with_base_uri(self, uri: impl Into<String>) -> Self

Sets the static base URI of the stylesheet (its location), against which document() resolves relative URIs given as strings.

Source§

impl Executable

Source

pub fn transform<'s>( &self, source: impl Into<Cow<'s, str>>, base_uri: Option<&str>, ) -> Result<Transformation, TransformError>

Runs the stylesheet on a document: xsl:apply-templates on its document node in the default mode, the result serialized. base_uri is the URI of the document: the base URI of its nodes, and the URI under which document() loads it again. As in Saxon-HE 12.10, it is not its document URI: document-uri(/) is empty.

The source text can be borrowed (&str, &String) or given (String), as for Document::parse: borrowed, the texts of its nodes are copied into the tree; given, the tree keeps the text and refers to it, so that the document is in memory once. A given text is kept as a copy only for a stylesheet that calls document() and a document with a base_uri, where document() may load the document again from its text.

§Errors

The document is not well-formed (or has a document type declaration), or the transformation raised a dynamic error.

Source

pub fn transform_with<'s>( &self, source: impl Into<Cow<'s, str>>, base_uri: Option<&str>, options: &TransformOptions<'_>, ) -> Result<Transformation, TransformError>

Executable::transform with options.

§Errors

As Executable::transform, and an invalid timezone or current date and time (or none given on a target without a system clock).

Source

pub fn transform_tree( &self, source: &Node, options: &TransformOptions<'_>, ) -> Result<TreeTransformation, TransformError>

Runs the stylesheet on a tree (source, a document node) and gives the result tree instead of its serialization, for a transformation whose result is read by another one. document() loads every document through the resolver of the options, the source’s own URI included.

§Errors

The source is not a document node, or the transformation raised a dynamic error; as Executable::transform_with otherwise.

Source

pub const fn serialization(&self) -> Serialization

The serialization parameters of the stylesheet’s xsl:output.

Source

pub fn transform_compact<'s>( &self, source: impl Into<Cow<'s, str>>, base_uri: Option<&str>, options: &TransformOptions<'_>, observer: &mut dyn ResultObserver, ) -> Result<CompactTransformation, TransformError>

Executable::transform_with, the result kept as a CompactOutput instead of a string, and read as it is written by observer: a large result in less memory, read without parsing its text.

§Errors

As Executable::transform_with.

Trait Implementations§

Source§

impl Debug for Executable

Source§

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

Formats the value using the given formatter. Read more

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