Re: [xsl] matching multiple times, outputting once?

Subject: Re: [xsl] matching multiple times, outputting once?
From: Goetz Bock <bock@xxxxxxxxxxx>
Date: Wed, 7 Nov 2001 09:59:25 +0100
> try adding these templates
> 
> <xsl:template match="*[@bold='Yes' ]">
> </xsl:template>
> 
> <xsl:template match="*[@bold='Yes' and @italic='Yes' ]">
> </xsl:template>
> 
> <xsl:template match="*[@bold='Yes' and @italic='Yes' and
> @underline='Yes' ]">
> </xsl:template>

while this will work for the mentioned cases, it will not work for all
    the combinationes there of: b, i, u, bi, bu, iu, ibu.

what about this:

<xsl:template match="emphasis">
  <xsl:call-template name="emphasis_b" />
</xsl:template>  

<xsl:template name="emphasis_b">
  <xsl:choose>
    <xsl:when test="@bold='Yes'">
      <b><xsl:call-template name="emphasis_i"/></b>
    </xsl:when>
    <xsl:otherwise>
      <xsl:call-template name="emphasis_i"/>
    <xsl:otherwise>
  </xsl:choose>  
<xsl:template>  
    
<xsl:template name="emphasis_i">
  <xsl:choose>
    <xsl:when test="@italic='Yes'">
      <i><xsl:call-template name="emphasis_u"/></i>
    </xsl:when>
    <xsl:otherwise>
      <xsl:call-template name="emphasis_u"/>
    <xsl:otherwise>
  </xsl:choose>  
<xsl:template>  

<xsl:template name="emphasis_u">
  <xsl:choose>
    <xsl:when test="@underline='Yes'">
      <i><xsl:value-of select="."/></i>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="."/>
    <xsl:otherwise>
  </xsl:choose>  
<xsl:template>  


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

Attachment: pgp00000.pgp
Description: PGP signature

Current Thread