|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Sorting things on two levels
Fantastic -- exactly what I was looking for, straightforward and simple. Will try this out tonight. Thanks! Michele -----Original Message----- From: Martin Honnen martin.honnen@xxxxxx [mailto:xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx] Sent: Tuesday, April 14, 2015 12:39 PM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Re: Sorting things on two levels Michele R Combs mrrothen@xxxxxxx wrote: >> Looks like grouping and sorting to me. Do you use XSLT 1.0 or 2.0? > > > I'll be running the transform using the latest version of Oxygen, so it looks like either would be fine. From the Oxygen Help file: With XSLT 2.0 here is an approach: <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs"> <xsl:output method="html" indent="yes"/> <xsl:template match="root"> <ul> <xsl:for-each-group select="indexterm" group-by="primary"> <xsl:sort select="current-grouping-key()"/> <li> <xsl:value-of select="current-grouping-key(), if (not(current-group()/secondary)) then current-group()/@id else ()" separator=", "/> <xsl:if test="current-group()/secondary"> <ul> <xsl:for-each-group select="current-group()" group-by="secondary"> <xsl:sort select="current-grouping-key()"/> <li> <xsl:value-of select="current-grouping-key(), current-group()/@id" separator=", "/> </li> </xsl:for-each-group> </ul> </xsl:if> </li> </xsl:for-each-group> </ul> </xsl:template> </xsl:stylesheet> Outputs <ul> <li>aardvarks, {ID}</li> <li>bears <ul> <li>breeding, {ID}</li> <li>feeding, {ID}</li> <li>hunting, {ID}, {ID}</li> </ul> </li> </ul> for your sample data.
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








