[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Sorting and Grouping Alphabetically: Two Levels

Subject: Re: Sorting and Grouping Alphabetically: Two Levels
From: David Carlisle <davidc@xxxxxxxxx>
Date: Tue, 8 Jan 2008 17:03:18 GMT
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,1))">&#10;</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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2011 All Rights Reserved.