xsl-list
[Top] [All Lists]

RE: Problem with grouping the handling of sibling nodes

2005-03-09 03:14:12
But what do you mean with the second pass. Do I have to invoke the 
transformer with another xsl or is it possible to invoke this second 
transformation within the original xsl file?

It's surprising how rarely this technique is taught and discussed. Splitting
complex transformations up into a pipeline of simple transformations is
something that ought to be a standard design pattern used by every XSLT
developer.

There are two ways of doing it: multiple stylesheets, and multiple phases
within a single stylesheet. I use both approaches, often within the same
pipeline.

Multiple stylesheets can be linked into a pipeline in a number of ways:

* with your own custom Java code, e.g. using the JAXP interfaces

* with a pipeline processor such as Orbeon

* from a shell script

* Saxon has a custom extension, saxon:next-in-chain, that allows one
stylesheet to direct its output to be processed by another stylesheet

Within a single stylesheet, a pipeline is expressed as a series of
variables:

<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:copy-of select="$phase-8-output"/>
</xsl:template>

To do this in XSLT 1.0, you need the xx:node-set() extension.

Using multiple stylesheets gives you greater modularity and reusability, but
is a bit more complex to deploy. Importantly, it also allows you to
incorporate steps into the pipeline [I've never been sure what a step in a
pipeline should be called!] that are implemented using technologies other
than XSLT - for example, STX, XQuery, Java SAX filters, Perl scripts.

Michael Kay
http://www.saxonica.com/



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>