[xsl] RE: multi-phase transformations (was untitled)

Subject: [xsl] RE: multi-phase transformations (was untitled)
From: "Michael Kay" <mhkay@xxxxxxxxxxxx>
Date: Wed, 14 Mar 2001 10:10:25 -0000
> I guess my general question is, how do you have one xsl
> output an xml file
> and then have a 2nd xsl automatically process it?
There are two approaches: the one-stylesheet approach and the
multi-stylesheet approach.

In the one-stylesheet approach, you need the node-set() extension to make
the output of the first phase accessible to the second. You also need to
ensure that the rules for each phase are kept separate. One way to do this
is with modes, another way is by using a different namespace for the source
tree and the intermediate tree. Putting the rules in different stylesheet
modules is helpful but doesn't itself solve the problem. The typical logic
(for three phases) is:

<xsl:variable name="phase1-output">
  <xsl:apply-templates select="/" mode="phase1"/>

<xsl:variable name="phase2-output">
  <xsl:apply-templates select="node-set($phase1-output)" mode="phase2"/>

<xsl:templates match="/">
  <xsl:apply-templates select="node-set($phase2-output)" mode="phase3"/>

The alternative multi-stylesheet approach is to control several
transformations linked together into a pipeline from the transformation API.
The TrAX API allows a transformation to be configured as a SAX Filter which
makes this very convenient.

Mike Kay
Software AG

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread