xsl-list
[Top] [All Lists]

sum of price * qty, without node-set()

2004-01-28 20:22:38
greetings all,
i'm a newbie and am trying to get a sum of a calculation; i'm hoping to get the value "162.00".

<BATCH>
  <RECEIPT>
    <qtyRcpt>1</qtyRcpt>
      <line>
        <pr>102.00</pr>
      </line>
  </RECEIPT>
  <RECEIPT>
    <qtyRcpt>3</qtyRcpt>
      <line>
        <pr>20.00</pr>
      </line>
  </RECEIPT>
</BATCH>

i've seen this FAQ:
http://www.dpawson.co.uk/xsl/sect2/N5121.html#d5351e202

but without the sample xml, i can't really understand it.

i've also seen posts that use the "node-set()" function. but i'm not able to successfully get the exslt stuff to work.

<xsl:template match="BATCH">
  <xsl:variable name="tmpTotal">
    <xsl:for-each select="RECEIPT">
      <item>
        <xsl:value-of select="( qtyRcpt * line/pr )"/>
      </item>
    </xsl:for-each>
  </xsl:variable>

  <xsl:variable name="myTotal" select="exslt:node-set($tmpTotal)"/>
  <xsl:value-of select="sum($myTotal/item)" />
</xsl:template>


so, i'd really like to be able to do this in native XSLT 1.0 (without node-set). could someone please point me in the right direction? seems like it would be really simple. i've been pounding my head for hours. thanks.

-charles


XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



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