Hi there gurus!
I am new to XML and XSLT, so my quiestion should be an easy one for you.
What i am trying to do is get average from CD 'price' element.
I failed using 'sequence' to get all avalues from price element. So i decided to 1) get SUM on price and store it in 'mySum' variable 2) get COUNT of the CDs and store it in 'myCount' 3) get value of '$mySum/$myCount' and store it in myRes variable.
The following code works fine and i see the values:
Code:
<xsl:variable name="mySum" select="sum(catalog/cd/price)"></xsl:variable>
<xsl:variable name="myCount" select="count(catalog/cd)"></xsl:variable>
<td><xsl:value-of select="$mySum"/></td>
<td><xsl:value-of select="$myCount"/></td>
but when i try:
Code:
<xsl:variable name="mySum" select="sum(catalog/cd/price)"></xsl:variable>
<xsl:variable name="myCount" select="count(catalog/cd)"></xsl:variable>
<td><xsl:value-of select="$mySum/$myCount"/></td>
or
Code:
<xsl:variable name="mySum" select="sum(catalog/cd/price)"></xsl:variable>
<xsl:variable name="myCount" select="count(catalog/cd)"></xsl:variable>
<xsl:variable name="myRes" select="$mySum/$myCount"/></xsl:variable>
<td><xsl:value-of select="$myRes"/></td>
it fails...
Can you guys help me out here?
Thanks in advance!