Using Saxon’s and Xalan’s Native Extensions
Problem
You want to know how to exploit some of the useful extensions available in these popular XSLT implementations.
Solution
This recipe is broken into a bunch of mini-recipes showcasing the
most important Saxon and Xalan extensions. For all examples, the
saxon
namespace prefix is associated with
http://icl.com/saxon, and the
xalan
namespace prefix is associated with
http://xml.apache.org/xslt.
You want to output to more than one destination
This book has used Saxon’s facility
several times
to output results to more than one file. Saxon uses the
saxon:output
element. It also provides the
xsl:document
element, but it will only work if the
stylesheet version attribute is 1.1 and is therefore not preferred.
The href
attribute specifies the output
destination. This attribute can be an attribute value template:
<saxon:output href="toc.html"> <html> <head><title>Table of Contents</title></head> <body> <xsl:apply-templates mode="toc" select="*"/> </body> </html> </saxon:output>
Xalan takes a significantly different approach to multidestination
output. Rather than one instruction, Xalan gives you three:
redirect:open
, redirect:close
,
and redirect:write
. The extension namespace
associated with these elements is xmlns:redirect = "org.apache. xalan.xslt.extensions.Redirect"
. For the most
common cases, you can get away with using
redirect:write
by itself because if used alone, it
will open, write, and close the file.
Each element includes a file ...
Get XSLT Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.