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

Is there a way to skip non-numerical data while forma

Subject: Is there a way to skip non-numerical data while formatting numbers?
From: "Rashmi Rubdi" <rashmi.sub@xxxxxxxxx>
Date: Sun, 15 Apr 2007 17:49:07 -0400
 Is there a way to skip non-numerical data while  forma
Hello Everyone,

I'm using XSLT 1.0 , and I'm trying to format numerical data in the
price, shipping elements of the input XML as fillows:

<xsl:value-of select="format-number(number(price), '##,##,.00')"/>

<xsl:value-of select="format-number(number(shipping), '##,##,.00')"/>

<xsl:value-of select="format-number(number(price+shipping), '##,##,.00')"/>

The above formatting works well, except when a non-numeric data is
encountered in the price or shipping nodes.

The above statements result in a value of NaN -- I was hoping for a
blank value instead of getting a value of NaN.

I'm trying to find the best way to handle the above case, I was
thinking of checking the type of the price and shipping nodes with an
xsl:if statements before attempting to format them - but adding an
xsl:if each time reduces the response time of the resulting document
because every price/ shipping node would be checked.

Please suggest if there is a better way to suppress the NaN in the
event that the node contains a non-numeric value.

Any suggestions appreciated.

-Rashmi

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.