|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Cannot get numeric value - what am I doing wrong?
An <xsl:variable> with content (rather than a select attribute) always evaluates to a result tree fragment. If you want a number, do <xsl:variable name="a"> ... computation ... </xsl:variable> <xsl:variable name="b" select="number($a)"/> Michael Kay # -----Original Message----- # From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx # [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of # Kyle Partridge # Sent: 18 March 2004 21:45 # To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx # Subject: Cannot get numeric value - what am I doing wrong? # # Hi all, # # This is probably an easy question for you to answer, but I'm stumped. # # I've got this variable I'm trying to assign a NUMERIC value to: # # <xsl:variable name="top-remove"> # <xsl:choose> # <xsl:when test="string($prior-break-regions)"> # <xsl:call-template name="add-up"> # <xsl:with-param name="set-one" # select="$prior-break-regions/@top"/> # <xsl:with-param name="set-two" # select="$prior-break-regions/@height"/> # </xsl:call-template> # </xsl:when> # <xsl:otherwise><xsl:value-of # select="number('0')"/></xsl:otherwise> # </xsl:choose> # </xsl:variable> # # It calls a template, "add-up" which takes two sets of number # node-sets and adds them all together. This, too, is supposed # to return a NUMERIC # value: # # <xsl:template name="add-up"> # <xsl:param name="set-one"/> # <xsl:param name="set-two"/> # <xsl:param name="index" select="1"/> # <xsl:param name="total" select="0"/> # <xsl:choose> # <xsl:when test="$index > count($set-one) or # $index > count($set-two)"> # <xsl:value-of select="number($total)"/> # </xsl:when> # <xsl:otherwise> # <xsl:call-template name="add-up"> # <xsl:with-param name="set-one" # select="$set-one"/> # <xsl:with-param name="set-two" # select="$set-two"/> # <xsl:with-param name="total" # select="$total + $set-one[$index] + $set-two[$index]"/> # <xsl:with-param name="index" # select="$index + 1"/> # </xsl:call-template> # </xsl:otherwise> # </xsl:choose> # </xsl:template> # # So...HOW COME I wind up with a Node-Fragment type assigned to # my variable, when all is said and done??? I need the value # to be a numeric value, so that when I test to see if it is # boolean true or false, it will react properly. # # Thanks, # KP # # # XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list # # XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








