This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: multi-phase transformations (was untitled)
- To: <xsl-list at lists dot mulberrytech dot com>
- Subject: [xsl] RE: multi-phase transformations (was untitled)
- From: "Michael Kay" <mhkay at iclway dot co dot uk>
- Date: Wed, 14 Mar 2001 10:10:25 -0000
- Reply-To: xsl-list at lists dot mulberrytech dot com
> 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>
<xsl:variable name="phase2-output">
<xsl:apply-templates select="node-set($phase1-output)" mode="phase2"/>
</xsl:variable>
<xsl:templates match="/">
<xsl:apply-templates select="node-set($phase2-output)" mode="phase3"/>
</xsl:template>
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