cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Verhage <pe...@ibuildings.nl>
Subject XSLT possible or use XSP?!
Date Fri, 19 Jan 2001 15:40:56 GMT
Sorry to bother you all with my question, but I'm having a little bit of
trouble. The XSLT specification seems not clear enough to this, and
maybe it's Cocoon which not let me do what I want do.

I have a list of prices:
<prices>
  <price>34.34</price>
  <price>33.34</price>
   ....
</prices>

I want to calculate the total of the above. I thought let's use XSLT for
this, so I tried it by using xsl:variable and a for-each loop:
<xsl:variable name="total" select="number(0)"/>
<xsl:for-each select="prices/price">
  <xsl:variable name="total" select="$total + number(current())"/>
</xsl:for-each>

This does not work. I think it's not part of the XSLT specification to
update a variable, but it could be that Cocoon does not let me do this
(?). So I want to calculate it in another way. Something like
<xsl:value-of select="prices/price[position()=1] +
prices/price[position()=2]"/> but make this somehow do an internal loop
so it get's all the values...

But maybe this is not possible with XSLT (which would be a big shame...
:/), and can I better use XSP for this. Can anyone confirm this to me,
of give a good solution?

Regards,

Peter

-- 
Peter Verhage       <peter@ibuildings.nl>
ibuildings.nl BV - information technology
http://www.ibuildings.nl -  0118 41 50 54

Mime
View raw message