Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] access to preceding-sibling in a sorted list

From: "Simon Ruf" <simon@--------->
To:
Date: 9/4/2007 2:20:00 PM
Thanks alot.
I haven't tried it yet but found quite some bit of information about
this grouping-thing and I think I'll be able to implement this - and
even better: I think this answers another not-yet-asked question I had
in mind.

Simon


On 9/4/07, David Carlisle <davidc@xxxxxxxxx> wrote:
>
> this is easier in xslt2 (where xsl-for-each-group does what you want) in
> xslt1 there are essentially two approaches.
>
> 1 (the "pipeline" approach) first sort the items, not adding the id
> attributes, but do it into a variable
>   <xsl:variable name="first-pass">
>     the code to generate a list of <li> elements
>   </xsl:variable>
>
> then use the xx:node-set() extension function taht most XSLT1 engines
> have to allow you to proxcess this, the sorted items now are siblins so
> you can do
>
>   <xsl:for-each select="xx:node-set($first-pass)/li">
>     <xsl:copy>
>       <xsl:if test="...."><xsl:attribute name="id".....
>
>
>
> 2 (the grouping approach)
> View it as a grouping problem, and use one of the XSLt 1 grouping idioms
> (google for muenchian grouping) for example You want to group on first
> letter, sort the groups, sort each item in each group and add an
> attribute on teh first
>
> <xsl:key name="l" match="card" use="substring(full-name,1,1)"/>
>
> <xsl:for-each
> select="card[generate-id()=generate-id(key('l',substring(full-name,1,1)))]">
>  <xsl:sort select="full-name"/>
> <xsl:variable name="letter" slect="key('l',substring(full-name,1,1)))"/>
> <xsl:for-each select="key('l',$letter)">
> <xsl:sort select="full-name"/>
> <li>
> <xsl:if test="position()=1"><xsl:attribute name="id"><xsl:value-of
> select="$letter/></xsl:attribute>
> <xsl:value-of select="full-name"/>
>
> (untested)
>
> David
>
> ________________________________________________________________________
> The Numerical Algorithms Group Ltd is a company registered in England
> and Wales with company number 1249803. The registered office is:
> Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.
>
> This e-mail has been scanned for all viruses by Star. The service is
> powered by MessageLabs.
> ________________________________________________________________________


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent