xsl-list
[Top] [All Lists]

[xsl] Is there a way to skip non-numerical data while formatting numbers?

2007-04-15 15:07:38
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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--