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

Re: Format Number and Empy Elements

Subject: Re: Format Number and Empy Elements
From: "Mark Anderson" <mark.anderson@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 8 Aug 2007 17:39:21 +0100
 Re: Format Number and Empy Elements
Hi Guys

I still have a few problems with this. Here's my sample XML

<numbers>
	<number>
		<id>A</id>
		<value></value>
	</number>
	<number>
		<id>B</id>
		<value>0</value>
	</number>
	<number>
		<id>C</id>
		<value>1000</value>
	</number>
	<number>
		<id>D</id>
		<value>-100</value>
	</number>
	<number>
		<id>E</id>
		<value>99.99</value>
	</number>
</numbers>

RESULTS

concat('0', value) works brilliantly, except when there are negative
numbers (as I get '0-100'). There's always a catch

Strangely, sum(value[.]) still gave NaN for Element A



Here's my XSL

<!-- concat('0',value)-->
<table>
	<xsl:for-each select="number">
		<tr>
			<td><xsl:value-of select="id"/></td>
			<td align="right"><xsl:value-of
select="format-number(number(concat('0', value)), '#,.00')"/></td>
		</tr>
	</xsl:for-each>
</table>

<!-- sum(value[.])-->
<table>
	<xsl:for-each select="number">
		<tr>
			<td><xsl:value-of select="id"/></td>
			<td align="right"><xsl:value-of
select="sum(value[.])"/></td>
		</tr>
	</xsl:for-each>
</table>

Forgot to mention, I'm stuck with XSLT 1.0 (bit I guess you figured that
out)

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.