xsl-list
[Top] [All Lists]

RE: Comparing two variables

2004-04-29 06:19:01

<!-- returns the last slide number -->
   <xsl:template name="find.lastslide">
     <xsl:value-of select="count(/xpresent/slide)"/>
   </xsl:template>

<!-- creates an "slideX.html" string -->
<xsl:template name="find.nextslide">
     <xsl:variable name="next" select="position() + 1"/>
     <xsl:variable name="last"><xsl:call-template
      name="find.lastslide"/></xsl:variable>
     <xsl:choose>
       <xsl:when test="$next &gt; $last">
      <xsl:variable name="result"><xsl:value-of 
select="$last"/></xsl:variable>
       </xsl:when>
       <xsl:otherwise>
      <xsl:variable name="result"><xsl:value-of
          select="$next"/></xsl:variable>
       </xsl:otherwise>
     </xsl:choose>
     <xsl:value-of select="concat('slide',$result,'.html')"/>
   </xsl:template>


You should get a compile-time error saying that the $result variable is not
in scope at the point where you use it.

Complain to your XSLT processor vendor (or switch to a different processor),
and change your code to:

<xsl:variable name="result">
      <xsl:choose>
       <xsl:when test="$next &gt; $last">
             <xsl:value-of select="$last"/>
        </xsl:when>
        <xsl:otherwise>
             <xsl:value-of select="$next"/>
        </xsl:otherwise>
      </xsl:choose>
</xsl:variable>
<xsl:value-of select="concat('slide',$result,'.html')"/>

Michael Kay



<Prev in Thread] Current Thread [Next in Thread>