Subject: Re: multiple transformations (pipelining) in one stylesheet
From: Oliver Lietz <list@xxxxxxxxxxxxxx>
Date: Fri, 19 Oct 2007 18:47:58 +0200
|
Am Freitag, 19. Oktober 2007 schrieb Michael Kay:
[...]
> Use modes to make it clear which templates apply to which phase of
> processing.
I tried to adapt your model (used your mode names to see if I understand it)
but there must be an error, I don't get any output.
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="UTF-8" omit-xml-declaration="yes"/>
<xsl:template match="@*|node()" mode="phase-1">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="acronym" mode="phase-1">
<xsl:value-of select="@text"/>
</xsl:template>
<xsl:template match="/" mode="phase-2">
<p>
<xsl:value-of select="/file/content/para"/>
</p>
</xsl:template>
<xsl:variable name="phase-1-output">
<xsl:apply-templates select="/" mode="phase-1"/>
</xsl:variable>
<xsl:variable name="phase-2-output">
<xsl:apply-templates select="$phase-1-output" mode="phase-2"/>
</xsl:variable>
<xsl:template match="/">
<xsl:apply-templates select="$phase-2-output" mode="phase-3"/>
</xsl:template>
</xsl:stylesheet>
So it works like this:
1) template (match="/") pulls in result from $phase-2-output
2) $phase-2-output is build by applying phase-2 templates to $phase-1-output
3) $phase-1-output is build by applying phase-1 templates to root of document
Am I right?
O.
|