RE: Recursive Template Application

Subject: RE: Recursive Template Application
From: Kay Michael <Michael.Kay@xxxxxxx>
Date: Mon, 19 Jun 2000 09:59:32 +0100
> This stylesheet works only half-way in that it correctly 
> transforms "<toc/>" to "<section .../>" but leaves it at that. The output
of T1 
> is not matched by T2. But how can I enforce this, so that "<toc/>" is 
> finally transformed to "<h2>..."? Should I run the XSL processor twice? Or
is there a more
> efficient way to accomplish this?
XSLT is a "single-pass" process, all template rules are applied to the input
document (or tree), there's no standard way within the language of applying
a second transformation to the result of the first.

There are two ways round this:

1: the node-set() extension (available in xt, saxon, and in a different form
in MSXML3). This allows you to convert a result-tree-fragment to a node-set.
So you first template rule can generate an r-t-f, you can then convert this
to a node-set, and apply further templates to that nodeset.

2: perform several transformations in series, using different stylesheets.
You can control this from the API of your chosen XSLT processor, or in the
case of Saxon, you can control it from within the stylesheet by writing e.g.
<saxon:output next-in-chain="phase2.xsl">

Mike Kay

 XSL-List info and archive:

Current Thread