2018-10-15 00:20
浏览 92

xslt sum连接而不是添加

so I am trying to write some xslt 1.0 and trying to sum some values but the sum() function concatenates the numbers (or strings) instead of summing up. I'll paste my xslt here.

<xsl:stylesheet version="1.0" xmlns:xsl=""  xmlns:exsl="">

    <xsl:template match="/">
        <table id="carttable" align="center">
            <xsl:for-each select="cart/item">
                    <td id="itemnum"><xsl:value-of select="itemnumber" /></td>
                    <td id="itemprice"><xsl:value-of select="itemprice" /></td>
                    <td><xsl:value-of select="quantity" /></td>
                    <td id="itemadd"><input type="button" id="removeBtn" value="Remove One From Cart">
                        <xsl:attribute name="onclick">
                            <xsl:value-of select="itemnumber" />
            <xsl:variable name="itemTotals">
                <xsl:for-each select="cart/item">
                        <xsl:value-of select="itemprice * quantity" />

                <td align="right">Total</td>
                    <xsl:value-of select="sum(exsl:node-set($itemTotals))" />


have looked at other questions on stackoverflow but couldn't find one that caters to my exact scenario. hoping to find some answers here :) TIA P.S. i'm using xslt 1.0 and using it in PHP


1条回答 默认 最新

相关推荐 更多相似问题