Re: [xsl] different templates

Subject: Re: [xsl] different templates
From: Goetz Bock <bock@xxxxxxxxxxx>
Date: Mon, 29 Oct 2001 10:53:59 +0100
On Mon, Oct 29 '01 at 10:29, Ingo Friepoertner wrote:
> I (think I) need 2 different apply-templates which match the same xml 
> node in a stylesheet.
What for?

> How can I do this without conflicts?
> 
> <xsl:template match="var"> <!-- foo --> </xsl:template>
> <xsl:template match="var"> <!-- bar --> </xsl:template>
Not at all, how should the processor (or anyone else) know when to use
which template?
 
> Well, there must be a simple solution ...

> Problem: I need the elements and id's from 'vars' in different parts of 
> html output.
You could use:
- modes
    <xsl:template match="var"> <!-- foo --> </xsl:template>
    <xsl:template match="var" mode="ids"> <!-- bar --> </xsl:template>
  and use
    <xsl:apply-templates />
    <xsl:apply-templates mode="ids" />
- for-each
    <!-- ... build your result -->
    <xsl:for-each select="var/@id">
      <!-- print id -->
    </xsl:for-each>
- there are more ways for sure ;-)

-- 
Goetz Bock                                              IT Consultant
Dipl.-Inf. Univ.

Attachment: pgp00017.pgp
Description: PGP signature

Current Thread