[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Calculating cumulative values and min/max

Subject: Calculating cumulative values and min/max
From: "Simon Shutter" <simon@xxxxxxxxxxx>
Date: Tue, 12 Jun 2007 21:44:21 -0700
 Calculating cumulative values and min/max
A few months ago I asked for some help with aggregating numbers in XSLT 1.0.
Andrew Welch provided the stylesheet below that worked just fine for my
needs.

I have a couple of follow-up questions:

a) in the predicate [@x = current()/@x], why is current node used and not
the context node used?  I guess I'm confused at to which @x is which in the
predicate.

b) is it possible to calculate min/max values is this only possible in
XSLT/XPATH 2.0?

Thanks, Simon


---------------------------------------------
Stylesheet
---------------------------------------------
<xsl:template match="point">
 <xsl:copy>
   <xsl:copy-of select="@*"/>
   <xsl:attribute name="y2">
     <xsl:value-of select="sum(./@y1|preceding-sibling::point[@x =
current()/@x]/@y1)"/>
   </xsl:attribute>
 </xsl:copy>
</xsl:template>

---------------------------------------------
Input
---------------------------------------------

<root id="theroot">
  <set id="1">
    <point x="1" y1="2" />
    <point x="1" y1="3" />
    <point x="1" y1="0" />
    <point x="1" y1="2" />
    <point x="1" y1="2" />
    <point x="2" y1="3" />
    <point x="2" y1="0" />
    <point x="2" y1="2" />
    <point x="3" y1="2" />
    <point x="3" y1="3" />
    <point x="3" y1="1" />
    <point x="3" y1="2" />
    <point x="3" y1="2" />
  </set>
  <set id="2">
    <point x="1" y1="2" />
    <point x="1" y1="3" />
    <point x="1" y1="0" />
    <point x="1" y1="2" />
    <point x="2" y1="2" />
    <point x="3" y1="2" />
    <point x="3" y1="2" />
    <point x="3" y1="2" />
  </set>
  <set id="n">
    <point x="1" y1="2" />
    <point x="1" y1="3" />
    <point x="1" y1="2" />
    <point x="2" y1="3" />
    <point x="2" y1="0" />
    <point x="2" y1="2" />
    <point x="3" y1="3" />
  </set>
</root>

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.