Re: [xsl] Help with Parameters

Subject: Re: [xsl] Help with Parameters
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 27 Sep 2006 20:47:18 +0100
> Unfortunately, the <desc> text that matches the  parameter is being
> output twice:

so you must  have two apply-templates, but you only showed one, so it's
a bit hard to guess. 

Cant't you just have a single template


<xsl:template match="desc" mode="leader">
 <xsl:param name="special_desc"/>
<xsl:choose>
<xsl:when test="$special_desc='yes'">
<fo:wrapper font-style="italic" font-weight="normal">
   <xsl:text>&#160;&#160;&#160;&#160;</xsl:text>
   <xsl:value-of select="."/>
  </fo:wrapper>
</xsl:when>
<xsl:otherwise>
 <xsl:if test="not(
  <fo:block margin-left="8em" font-style="italic" font-weight="normal">
   <xsl:apply-templates select="@* | *[contains(@type, $my_version) or string-length(@type)=0] | text()"/>
  </fo:block>
</xsl:otherwise> 
</xsl:choose>
</xsl:template>

But still even with one template you are (probbaly) going to get things output
twice if you apply templates twice.



Incidentally don't do
<xsl:with-param name="special_desc">yes</xsl:with-param>
which makes a result tree fragment with a root node and a text node,
which is relatively expensive, just do
<xsl:with-param name="special_desc" select="'yes'"/>
which makes a string, or in this case, even better would be
<xsl:with-param name="special_desc" select="true()"/>
which you could test directly as

 <xsl:param name="special_desc" select="false()"/>
<xsl:choose>
<xsl:when test="$special_desc">


David

Current Thread