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
impl Executable
Sourcepub fn new(sheet: &Stylesheet) -> Result<Self, PrepareErrors>
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).
Sourcepub fn with_base_uri(self, uri: impl Into<String>) -> Self
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
impl Executable
Sourcepub fn transform<'s>(
&self,
source: impl Into<Cow<'s, str>>,
base_uri: Option<&str>,
) -> Result<Transformation, TransformError>
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.
Sourcepub fn transform_with<'s>(
&self,
source: impl Into<Cow<'s, str>>,
base_uri: Option<&str>,
options: &TransformOptions<'_>,
) -> Result<Transformation, TransformError>
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).
Sourcepub fn transform_tree(
&self,
source: &Node,
options: &TransformOptions<'_>,
) -> Result<TreeTransformation, TransformError>
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.
Sourcepub const fn serialization(&self) -> Serialization
pub const fn serialization(&self) -> Serialization
The serialization parameters of the stylesheet’s xsl:output.
Sourcepub fn transform_compact<'s>(
&self,
source: impl Into<Cow<'s, str>>,
base_uri: Option<&str>,
options: &TransformOptions<'_>,
observer: &mut dyn ResultObserver,
) -> Result<CompactTransformation, TransformError>
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.