RE: [xsl] Muenchian method, and keys 'n stuff

Subject: RE: [xsl] Muenchian method, and keys 'n stuff
From: DPawson@xxxxxxxxxxx
Date: Wed, 23 Jan 2002 13:19:15 -0000
Jeni wrote:

> First, an iteration over the alphabet, which I'll do using the method
> Dimitre suggested (since this is the only one that's actually
> supported in the current WDs).

Is the context not 'wrong' since it becomes the string in the variable?



> A key might be more efficient, but to make it simple, I'll just
> collect the r elements by their Ra/lett equalling the $letter:
> 
>   <xsl:for-each select="1 to string-length($l)">
>     <xsl:variable name="letter" select="substring($l, ., 1)" />
>     <xsl:variable name="books" select="r[Ra/lett = $letter]" />

I.e. books won't be selected, because the context will be
  the variable?
Or is the context not changed when used like this?
  (at variance with 1.0)



> Within the xsl:when, we want to group the books by their Ra/auth. This
> is very easy in XSLT 2.0 with the xsl:for-each-group instruction,
> using the group-by attribute:
> 
>   <xsl:for-each select="1 to string-length($l)">
>     <xsl:variable name="letter" select="substring($l, ., 1)" />
>     <xsl:variable name="books" select="r[Ra/lett = $letter]" />
>     <xsl:choose>
>       <xsl:when test="$books">
>         <xsl:for-each-group select="$books"
>                             group-by="Ra/auth">
>           <h2><xsl:value-of select="Ra/auth" /></h2>
>           ...
>         </xsl:for-each-group>

Now that is neat!

> And finally to apply templates to each of the r elements to get their
> details, we retrieve the r elements in the particular author group
> using the current-group() function:
> 
>   <xsl:for-each select="1 to string-length($l)">
>     <xsl:variable name="letter" select="substring($l, ., 1)" />
>     <xsl:variable name="books" select="r[Ra/lett = $letter]" />
>     <xsl:choose>
>       <xsl:when test="$books">
>         <xsl:for-each-group select="$books"
>                             group-by="Ra/auth">
>           <h2><xsl:value-of select="Ra/auth" /></h2>
>           <xsl:apply-templates select="current-group()" />

I see what Steve meant, when he said his namesake method is
now redundant! And him only 21!


Regards DaveP. Again, thanks Jeni.


- 

NOTICE: The information contained in this email and any attachments is 
confidential and may be legally privileged. If you are not the 
intended recipient you are hereby notified that you must not use, 
disclose, distribute, copy, print or rely on this email's content. If 
you are not the intended recipient, please notify the sender 
immediately and then delete the email and any attachments from your 
system.

RNIB has made strenuous efforts to ensure that emails and any 
attachments generated by its staff are free from viruses. However, it 
cannot accept any responsibility for any viruses which are 
transmitted. We therefore recommend you scan all attachments.

Please note that the statements and views expressed in this email 
and any attachments are those of the author and do not necessarily 
represent those of RNIB.

RNIB Registered Charity Number: 226227

Website: http://www.rnib.org.uk 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread