This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: Variables and constants


<gasp/> <xsl:for-each... inside <xsl:variable.

It is nice to have mathematicians on the list :-)

Gathers a list of nodes into the variable,
then the sum 'adds 'em up'

Impressed David.

Regards, DaveP


><total xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>       xsl:version="1.0"
>       xmlns:xt="http://www.jclark.com/xt"
>                >
>
><xsl:variable name="x">
>  <xsl:for-each select="x/thing">
>    <a><xsl:value-of select="quantity * price"/></a>
>  </xsl:for-each>
></xsl:variable>
>
><xsl:value-of select="sum(xt:node-set($x)/a)"/>
>
></total>
>
>xt basket.xml basket.xsl 
><?xml version="1.0" encoding="utf-8"?>
><total>54</total>


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]