Re: Sorting and Grouping Alphabetically: Two Levels
> So sorry. x:node-set() is not available. blugh which processor are you using? > I realize that the display I represented requires the > extra mark-up and I can easily put that in later the structure of the xslt for text is (or can be) very different. Consider just one step of your problem adding a blank line between letters (assuming sorting is done. If you are just generating text, you don't need to group anything, you just need to put out a blank line every now and then <xsl:for-each seelct="*"> <xsl:value-of select="."/> <xsl:if tests="not(substring(.,1,1)=substring(following-sibling::*,1,1))"> </xsl:if> </xsl:for-each> If however you need to produce markup, say putting all the rows that start with the same letter in a div then you need to group all the elements that start with the same letter together so in xslt 2 <xsl:for-each-group group-by="substring(.,1,1)"> <div> <xsl:copy-of select="current-group()"/> </div> </xsl:for-each-group> or, as we used to write it in xslt 1, <xsl:key name="l1" match="*" use="substring(.,1,1)"/> <xsl:for-each select="*[generate-id()=generate-id(key('l1',substring(.,1,1)))]"> <div> <xsl:copy-of select="key('l1',substring(.,1,1))"/> </div> </xsl:for-each> David
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