Subject: [xsl] Calculating cumulative values and min/max From: "Simon Shutter" <simon@xxxxxxxxxxx> Date: Tue, 12 Jun 2007 21:44:21 -0700 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] How to remove "xmlns" att, G. Ken Holman | Thread | Re: [xsl] Calculating cumulative va, Andrew Welch |
RE: [xsl] How to remove "xmlns" att, Chaudhary, Harsh | Date | [xsl] xsl table, Andreas Peter |
Month |