RE: [xsl] Using mode to override templates

Subject: RE: [xsl] Using mode to override templates
From: "Andrew Welch" <awelch@xxxxxxxxxxxxxxx>
Date: Tue, 2 Jul 2002 09:49:20 +0100
Peter,

For this to work I would need to replace all occurances of:

<xsl:apply-templates/>

with:

<xsl:choose>
   <xsl:when test="$print = 'yes'">
     <xsl:apply-templates mode="print"/>
   </xsl:when>
   <xsl:otherwise>
     <xsl:apply-templates/>
   </xsl:otherwise>
</xsl:choose>

Not such a big deal I suppose, especially if I isolate all the cases
where a call to a print template is possible.  

I guess I was just hoping for some kind of workaround.

cheers
andrew


-----Original Message-----
From: Hunsberger, Peter [mailto:Peter.Hunsberger@xxxxxxxxxx]
Sent: 01 July 2002 16:25
To: 'xsl-list@xxxxxxxxxxxxxxxxxxxxxx'
Subject: RE: [xsl] Using mode to override templates


>> Obviously, apply-templates with a mode will only use templates with a
>> matching mode (and not fire all the templates that are common to both
>> and therefore would not have a mode) - how do I overcome this?
>
> Andrew,
> how about just making the non print templates and the common code
explicit?
> IE:

Arg, correction, the otherwise isn't needed; that code should always be
fired...

  <xsl:choose>
   <xsl:when test="$print = 'yes'">
     <xsl:apply-templates mode="print"/>
   </xsl:when>
   <xsl:when test="$print != 'yes'">
     <xsl:apply-templates mode="not_print"/>
   </xsl:when>
 </xsl:choose>
 <xsl:apply-templates/>	<!-- common templates -->


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





---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.350 / Virus Database: 196 - Release Date: 17/04/2002
 

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.350 / Virus Database: 196 - Release Date: 17/04/2002
 

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


Current Thread