fn:transform
Invokes a transformation using a dynamically-loaded XSLT stylesheet.
transform($options as map(*)) ➔ map(*)
Arguments | ||||
| $options | map(*) | The input options for the transformation | |
Result | map(*) | |||
Namespace
http://www.w3.org/2005/xpath-functions
Links to W3C specifications
XPath 3.1 Functions and Operators
XPath 4.0 Functions and Operators
Saxon availability
Available in XPath 3.1, XSLT 3.0, XQuery 3.1, and later versions. From Saxon 9.8, available in all editions. Implemented in Saxon-PE and Saxon-EE since Saxon 9.7. Available for all platforms.
Notes on the Saxon implementation
Available since Saxon 9.7. The input options available are listed in the specification, with the additions and caveats noted below.
The following options are available:
-
source-location. Since 9.8.0.8.
The top-level option
source-locationhas the same effect assource-nodeexcept that it supplies the location of a source (lexical XML) document rather than a parsed XDM tree. This option is useful if the target transformation is streamed; it has been added as an extension to the spec because there is no other way of executing a stylesheet that expects a streamed input document. vendor-options/saxon:configuration. Since 9.8.0.8
.The
vendor-optionsparameter allows an entry of the form"vendor-options": map {QName('http://saxon.sf.net/', 'configuration'): $config}where$configis the root node of a configuration file expressed as an XML tree. If this option is present, the target transformation is run in a different configuration from the calling application, so that settings in the configuration file do not affect the environment of the caller. The calling and called configurations share the sameNamePooland document number pool, so that XDM nodes can be safely passed from one environment to the other; however they do not share the same schema components, so typed (schema-validated) documents cannot be passed.Options that can usefully be set in the target configuration file include the URIs and locations of schema documents and of XSLT library packages.
-
vendor-options/saxon:schema-validation
Validation of source documents may be requested either (a) by supplying a configuration file in which the option
<global schemaValidation="strict"/>has been set, or (b) by setting the option"vendor-options": map {QName('http://saxon.sf.net/', 'schema-validation'): 'strict'}. (The value'lax'can also be used.) Either option affects documents supplied using thesource-node,source-location, orglobal-context-itemoptions. Setting the option in the configuration file also affects documents read using thedoc()ordocument()functions. Neither option affects documents supplied in theinitial-match-selectionoption, or in any of thexxx-paramsoptions (such asstylesheet-params). -
vendor-options/saxon:write-result-documents. Since 13.0.
The vendor option
map {QName('http://saxon.sf.net/', 'write-result-documents'): true()}may be set to causexsl:result-documentinstructions to write output directly to filestore, rather than returning them in thefn:transformresult map. More specifically, iffn:transformis called from XSLT, then result documents produced by the target stylesheet are handled using the result document handler registered for the primary transformation; if it is invoked from XQuery, they are output using the default result document handler, which writes to filestore.Note that the default value of
base-output-urifor the target transformation is taken from the current output base URI of the invoking transformation, assuming the invocation is from XSLT.
To enable use of XSLT 4.0 features in the called stylesheet, it is not enough simply to
set xsl:stylesheet/@version="4.0" in the called stylesheet module. Instead,
you need to do two things:
-
Ensure that 4.0 is enabled in the calling stylesheet (or query)
-
Use the option
xslt-version="4.0"in the options passed to thefn:transformcall.