Hi Michael
I use 1.0 and the muenchian method helped me out, BUT how do I sort the resulting items from the grouping? My xsl:sort on documenttitle does not have any effect, why is that?
<xsl:for-each select="document[generate-id() = generate-id(key('documents-by-id', documentid)[1])]">
<xsl:sort data-type="text" select="documenttitle" order="ascending" />
<xsl:for-each select="key('documents-by-id', documentid)">
<xsl:sort select="version"
data-type="number"
order="descending" />
<xsl:if test="position() = 1">
<xsl:apply-templates select="current()">
</xsl:apply-templates>
</xsl:if>
</xsl:for-each>
</xsl:for-each>
Quote:
quote:Originally posted by mhkay
This is a classic grouping problem, the only quirk being that instead of displaying all the members of a group (grouped together) you display only the last member. If you're using XSLT 1.0, use Muenchian grouping (http://www.jenitennison.com/xslt/grouping). In 2.0, do
<xsl:for-each-group select="document" group-by="documentid">
<xsl:apply-templates select="current-group()[last()]"/>
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
|