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 [(_at_)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[(_at_)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>
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--