On 27 July 2011 19:59, Mark <mark(_at_)knihtisk(_dot_)org> wrote:
Hello Michael,
I'm not sure I understood the '+' in <xsl:for-each
select+"current-group()">
typo... :)
I tried the below template. [1] gives me the <Stamp> elements grouped under
<Date> but not sorted by value. [2] gives me the <Stamp> elements sorted by
value but not grouped under <Date>. Clearly I am missing something as I am
quite week in XPath. Where am I going wrong.
The code below does what you need. Directly within the for-each-each
group the context is the sequence of <Stamp> elements all with the
same year/month/day. The sort there sorts on that value. Then the
for-each inside there processes that seqeunce (that all have the same
year/month/day one at a time, sorted by the value. I've used a
different wrapper element for each group to help show what is going
on.
<xsl:template match="List">
<xsl:element name="List">
<xsl:for-each-group select="Item/Stamp"
group-by="Date/concat(@year, @month, @day)">
<xsl:sort select="current-grouping-key()" data-type="number"/>
<xsl:element name="Group{position()}">
<xsl:for-each select="current-group()">
<xsl:sort select="@value" order="descending"
data-type="number"></xsl:sort>
<xsl:copy-of select="." copy-namespaces="no"/>
</xsl:for-each>
</xsl:element>
</xsl:for-each-group>
</xsl:element>
</xsl:template>
--
Andrew Welch
http://andrewjwelch.com
--~------------------------------------------------------------------
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>
--~--