xsl-list
[Top] [All Lists]

Re: [xsl] Sorting and Grouping Alphabetically: Two Levels

2008-01-08 10:04:16

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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--