[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?

Subject: RE: Cannot get numeric value - what am I doing wrong?
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Thu, 18 Mar 2004 22:30:41 -0000
xsl variable numeric
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 &gt; count($set-one) or 
# $index &gt; 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


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.