[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Problem with grouping the handling of sibling node

Subject: RE: Problem with grouping the handling of sibling nodes
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 9 Mar 2005 10:14:12 -0000
sibling complex problem
> 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/

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.