This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: apply two different templates at the same time


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]