Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Re: Advanced sort >Thread Next - Re: Advanced sort Re: Advanced sortTo: NULL Date: 3/15/2009 10:53:00 AM Delf a écrit :
> Wrong...
I think this is a solution:
<xsl:key name="id" match="tag" use="." />
<xsl:variable name="groupTagList">
<tags>
<xsl:for-each select="//data/items/item[ @isVisible = '1' ]
/tags/tag[ generate-id( . ) = generate-id( key( 'id', . )[1] )]">
<tag>
<xsl:attribute name="number">
<xsl:value-of select="count( //data/items/
item[ @isVisible = '1' ]/tags/tag[ . = current() ] )" />
</xsl:attribute>
<xsl:value-of select="." />
</tag>
</xsl:for-each>
</tags>
</xsl:variable>
<xsl:variable name="tagList">
<tags>
<xsl:apply-templates select="msxsl:node-set(
$groupTagList )//tags/tag" mode="sorting">
<xsl:sort select="@number" data-type="number" order="descending" />
<xsl:sort select="." data-type="text" order="ascending" />
</xsl:apply-templates>
</tags>
</xsl:variable>
<xsl:template match="tag" mode="sorting">
<xsl:copy-of select="." />
</xsl:template>
And I get the following output:
achat conpulsif (2)
art (2)
peinture (2)
musique (1)
piano (1)
Order by DESC number and then ASC label.
--
Delf
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
