You are here

Some Random xsltproc Tips

The xsltproc command allows the processing of an XML document with an XSLT template.

xsltproc rentalouts.xslt rentalouts.xml

Text 1: Perform the transform "rentalouts.xslt" on the document "rentalouts.xml".

A lesser known feature of xsltproc is the ability to pass parameters - these become XSLT variables - to the transformation.

xsltproc  --stringparam sales_id 15 DailyRentalOutNotice.xslt -

Text 2: Perform the "DailyRentalOutNotice.xslt" transform on the XML document read from standard input with a variable $sales_id having a value of "15".

Addition useful directives are --repeat (which runs the transform 20 times) and --timing (which outputs the run-time information of the transform). These directives allow for much easier and more accurate performance testing/tuning of a transformation than running xsltproc under time, for example.

If you've ever been curious what XSLT extensions your xsltproc supports [this may vary by build] you can dump the known extension using the --dumpextensions parameter.

$> xsltproc --dumpextensions
Registered XSLT Extensions
--------------------------
Registered Extension Functions:
{http://exslt.org/crypto}md5
{http://exslt.org/math}random
{http://exslt.org/math}abs
...

Text 3: xsltproc reporting its supported extensions.

author: Adam Tauno Williams

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer