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

Re: xsl:apply-templates to all but...

Subject: Re: xsl:apply-templates to all but...
From: andrew welch <andrew.j.welch@xxxxxxxxx>
Date: Fri, 17 Feb 2006 13:59:51 +0000
andrew ducharme
On 2/17/06, Bob DuCharme <bob@xxxxxxxx> wrote:
> xsl:apply-templates to all but...
>
> I was curious about opinions on a processing trick I've been doing lately.
> The issue: if element w has content model (x,y,z) and I want to output its
> contents in (y,z,x) order, I could do this:
>
>   <xsl:template match="w">
>     <xsl:apply-templates select"y"/>
>     <xsl:apply-templates select"z"/>
>     <xsl:apply-templates select"x"/>
>   </xsl:template>
>
> But if something later gets added to that content model, this template
> rule will ignore it. If @select could take a regular expression more
> complex than * or ns:*, that would be cool, but that's not an option. So
> here's what I've done:
>
>   <xsl:template match="w">
>     <xsl:apply-templates select"y" mode="output"/>
>     <xsl:apply-templates select"*"/>
>   </xsl:template>
>
>   <xsl:template match="y" mode="output">
>     <!-- process normally -->
>   </xsl:template>
>
>   <xsl:template match="y"/>
>
> x and z get processed normally. (In real life, this was with larger, more
> complex content models and template rules.)
>
> Has anyone else done this? Or something similar, and if different, how so?

But the output here would be Y X Z not Y Z X....... have you let out
the X matching templates which would mirror the Y matching templates?

Even so, couldn't you just do:

<xsl:template match="w">
  <xsl:apply-templates select="y"/>
  <xsl:apply-templates select="z"/>
  <xsl:apply-templates select="*[not(self::y)][not(self::z)]"/>
</xsl:template>

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.