[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Comparing two variables

Subject: RE: Comparing two variables
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Thu, 29 Apr 2004 14:19:01 +0100
comparing two variables in xsl
> <!-- 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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.