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

Re: Multiple tranformations of a given element using X

Subject: Re: Multiple tranformations of a given element using XSL
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Wed, 11 Dec 2002 02:17:41 -0800 (PST)
tranformations
"Michael Kay" <michael.h.kay@xxxxxxxxxxxx> wrote in message
news:000c01c2a0f7$c5c12150$6401a8c0@xxxxxxxxxx
> >
> > To make it more clear, after I change an element name
> > during the first pass, if I would like to change the
> > content of the element during the second pass, the
> > second template is working on the source tree (which
> > is never modified) and hence the first change is being
> > compromised on the output tree. If there is a way I can make
> > the second template work on the DOM modified by the first
> > template, then I can probably use the new element name in the
> > 'match' variable of the second template.
> >
> > In essence, the first set of templates will modify the
> > DOM during the first pass, the modified DOM will be
> > the source tree for the second set of templates and so
> > on.
> >
>
> Yes, it's perfectly possible to write multi-pass transformations, and
> it's often a good way of keeping your stylesheets well-structured and
> modular, even in cases where a single-pass solution is feasible.
>
> There are two approaches: using multiple transformations with
multiple
> stylesheets, and using a single transformation with multiple phases
> within a single stylesheet.
>
> In the first approach you control the sequence of transformations
from
> the processor's API. This is particularly convenient to do using JAXP
in
> the Java world, but it's not difficult with Microsoft's API either.
>
> In the second approach you need to use a temporary tree and the
> xx:node-set extension. The typical logic is:
>
> <xsl:template match="/">
>   <xsl:variable name="temp">
>     <xsl:apply-templates select="/" mode="phase1"/>
>   </xsl:variable>
>   <xsl:apply-templates select="xx:node-set($temp)" mode="phase2"/>
> </xsl:template>
>
> You can of course implement the two modes (phases) in different
> stylesheet modules if you wish.
>
> Another approach is Saxon's "next-in-chain" extension which allows
one
> stylesheet to nominate another stylesheet that is used to process the
> result tree from the first stylesheet.
>
> Incidentally, it's probably best not to use the term DOM to refer to
> trees in the XPath data model: there are many differences between the
> DOM model and the XPath model. Microsoft blur the distinction by
> implementing both models in one product.
>
> Michael Kay
> Software AG
> home: Michael.H.Kay@xxxxxxxxxxxx
> work: Michael.Kay@xxxxxxxxxxxxxx
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>

The clean way to perform multipass processing is using functional
composition. Do have a look at the article:
"Dynamic Functions using FXSL: Composition, Partial Applications and
Lambda Expressions" at:
http://fxsl.sourceforge.net/articles/PartialApps/Partial%20Applications.html

Also, from a historical perspective, the following might be
interesting:
http://sources.redhat.com/ml/xsl-list/2001-06/msg01147.html





=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

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


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.