$result := xslt [--doc|:d | --precompiled|:p] [--string] expression [document name=xpath [name=xpath ...]]$pre_compiled := xslt [--compile|:c] expression


transform, xsl, xsltproc, process


This function compiles a given XSLT stylesheet and/or transforms a given document with XSLT.

A XSLT stylesheet is specified in the first argument either as a file name (default), or as a document (--doc or :d), or as a precompiled XSLT stylesheet object (--precompiled or :p - see --compile above).

If --compile or :c is used, compile a given XSLT stylesheet and return a compiled XSLT stylesheet object. This object can be later passed as a XSLT stylesheet to xslt --precompiled.

Without --compile or :c, transform a given document (or - if used with only the stylesheet argument - the current document) using a given XSLT stylesheet and return the result.

All arguments following the second (document) argument are considered to be stylesheet parameters and (after expanding ${...} interpolators) are directly passed to the XSLT engine without being evaluated by XSH2. All stylesheet parameters should be of the form name=xpath (possibly in brackets).

Example 61. Process current document with XSLT

$result := xslt stylesheet.xsl . font='14pt' color='red'

Example 62. Same for several documents, reusing the XSLT stylesheet

$xslt := xslt --compile stylesheet.xsl;
foreach my $file in {qw(f1.xml f2.xml f3.xml)} {
  save --file {"out_$file"} &{xslt --precompiled $xslt &{ open $file } font='14pt' color='red'};