This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Using mode to override templates
- From: "Andrew Welch" <awelch at piper-group dot com>
- To: <xsl-list at lists dot mulberrytech dot com>
- Date: Mon, 1 Jul 2002 15:18:01 +0100
- Subject: [xsl] Using mode to override templates
- Reply-to: xsl-list at lists dot mulberrytech dot com
..apologies if this has been discussed before
I want to merge my print and my 'screen' stylesheets into one to aid
maintainability. Ideally I want to do this:
<xsl:when test="$print = 'yes'">
<xsl:apply-templates mode="print"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
</xsl:otherwise>
With all templates firing as usual, except those with the mode overiding
their non-mode counterparts.
(essentially only a few templates have the mode attribute, such as
tables (remove scrolling)) and inline graphics.
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?
I suppose on each template I could use a big if-else (or choose-when ;)
and separate the code that way, but I would prefer to use the neater
mode approach if thats possible.
cheers
andrew
---
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