[XSL-LIST Mailing List Archive Home]
[xsl] Grouping- Any Better Suggestion?
Subject: [xsl] Grouping- Any Better Suggestion?|
From: Vasu Chakkera <vasucv@xxxxxxxxx>
Date: Thu, 13 Oct 2011 09:53:33 +0100
I have a funny grouping issue, and I have a solution to that. I
wondered if there were better ways to do it..
The problem definition is as follows:
I have a list of points in my XML and each point belongs to one area.
I need to print a heading of the area and then put all the points
underneath in a new line..
point1 - area A
point2 - area A
point3 - area A
point4 - area B
point5 - area B
point6 - area B
point7 - area B
point8 - area C
point9 - area C
point10 - area C
I wanted to print
I can do this easily by saying...
<xsl:for-each-group select="//staticpoint" group-by="area">
<h1>AREA : <xsl:value-of select="area"/></h1>
I called this a little funny because What I want is that the last
point in the the current group should allways be shown as the first in
the second group. You can imagine this as the union area in the Venn
diagram .. where a point can belong to two areas. the business says
that at that point since the second area starts, technically it
belongs to the second area.
The solution i had was that I will regroup these points and have
another attribute where I will add the value of the changing area to
the last element in that group.
<!-- last point , after which the area changes -->
<xsl:when test="not(area =
And then do a regular grouping on the staticpoint/@group
Anybody has any better ideas?