This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: apply two different templates at the same time
- From: Oliver Becker <obecker at informatik dot hu-berlin dot de>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Thu, 31 Jan 2002 11:26:24 +0100 (MET)
- Subject: Re: [xsl] apply two different templates at the same time
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hi Andrew,
> I have a load of data and a load of templates, and it all gets displayed
> nicely. If any of the elements in the data contain an attribute 'mark="1"'
> then the data should be highlighted by changing its background colour. The
> mark attribute can apply to any element in the data.
>
> Currently, I use two templates for each element - one matching just the
> element and one matching the element with the 'mark' attribute...
Create a new stylesheet with the following content:
<xsl:import href="your-original-stylesheet.xsl" />
<xsl:template match="*[@mark=1]">
<highlight>
<xsl:apply-imports />
</highlight>
</xsl:template>
Probably <highlight> is actually something like <div class="marked"> ...
Use this new stylesheet and it should do what you want.
In "your-original-stylesheet.xsl" you don't have to care about the mark
attributes.
I currently don't know if there's a simpler solution with XSLT 2.0
Cheers,
Oliver
/-------------------------------------------------------------------\
| ob|do Dipl.Inf. Oliver Becker |
| --+-- E-Mail: obecker@informatik.hu-berlin.de |
| op|qo WWW: http://www.informatik.hu-berlin.de/~obecker |
\-------------------------------------------------------------------/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list