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

Re: access to preceding-sibling in a sorted list

Subject: Re: access to preceding-sibling in a sorted list
From: "Simon Ruf" <simon@xxxxxxxxx>
Date: Tue, 4 Sep 2007 16:20:04 +0200
Re:  access to preceding-sibling in a sorted list
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.
> ________________________________________________________________________

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-2007 All Rights Reserved.