xsl-list
[Top] [All Lists]

[xsl] Re: Format Number and Empy Elements

2007-08-08 09:39:55
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)


--~------------------------------------------------------------------
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>
--~--

<Prev in Thread] Current Thread [Next in Thread>