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

Can you embed a filter test ahead of the format-number

Subject: Can you embed a filter test ahead of the format-number function in the xsl:value-of method
From: jdgarrett@xxxxxxxxxx
Date: Tue, 6 Nov 2001 11:51:25 -0600
format number returns nan
Given the following XML snippet


<NodeSomething  attribute1="1234" attribute2="3">5678</NodeSomething>
<NodeSomething  attribute1="12"   attribute2="">Abc</NodeSomething>
<NodeSomething  attribute1="1256" attribute2="45">456</NodeSomething>
<NodeSomething  attribute1="1298" attribute2="">8899</NodeSomething>

I would like to change the following XSLT (which works but is code bloat)

<xsl:for-each select="NodeSomething">
<xsl:if test="./@attribute2 != ''">
	<xsl:value-of select="format-number(./@attribute2,"#,###.00")"/>
</xsl:if>
</xsl:for-each>


to the following (so that I can optimize the code)

<xsl:for-each select="NodeSomething">
	<xsl:value-of select="[./@attribute2 !=
'']format-number(./@attribute2,"#,###.00")"/>
</xsl:for-each>


is it possible to embed a filter test ahead of the format-number function in
the xsl:value-of so
that if the filter test was true then and only then it would call the
format-number
function on the selected attribute rather than doing the xsl:if test and
then
calling the xsl:value-of method ??

As you know, if attribute2 is empty then I get a NaN which format-number
returns NaN
rather than just nothing ....

Please advise
Thank You
JGarrett




 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.