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

RE: current-group()[1] within xsl:for-each-group

Subject: RE: current-group()[1] within xsl:for-each-group
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 2 Mar 2005 15:25:46 -0000
xsl for each group
> I've got this in a template:
> 
>       <xsl:for-each-group select="mb3e:document" 
> group-by="mb3e:fam_id">
>         <xsl:sort select="mb3e:prim_sort_key"/>
>         <xsl:variable name="first-structured-number"
>                       
> select="esd:structured-number(current-group()[1])"/>
>         <xsl:apply-templates mode="mil" select="current-group()">
>           <xsl:with-param name="family-structured-number"
>                           select="$first-structured-number"/>
>           <xsl:sort select="mb3e:date_list/mb3e:date[@type='PUBL']"
>                     order="descending"/>
>         </xsl:apply-templates>
>       </xsl:for-each-group>
> 
> The esd:structured-number function is slow, so I only want to call it
> once per group.  Actually, the template that is applied within the
> xsl:for-each-group instruction has to call it for each mb3e:document
> element, but I want to avoid calling it more than once for 
> any of those
> elements (including the first, i.e. most recent):

I'm not sure what you mean by "the most recent document". current-group()[1]
selects the first item in the group currently being processed. You haven't
really shown enough of your source data for me to understand what you are
doing.
> 
>   <xsl:variable name="structured-number"
>                 select="if (position() = 1)
>                         then $family-structured-number
>                         else esd:structured-number(.)"/>

Where is this variable declared, and where is it used? The reference to
position() makes it highly context-sensitive. 
> 
> I think this works most of the time, but sometimes the
> family-structured-number parameter value (i.e. 
> $first-structured-number)
> is not the value that would be returned if the esd:structured-number
> function were called on the most recent mb3e:document element in the
> group.  For example, in once case it was the 7th most recent 
> of a group of 58.

As I say, I don't understand what you mean by "most recent", and I don't see
anything in your code that relates to the concept. You seem to be basing the
calculation on the first item in the current group.

Michael Kay
http://www.saxonica.com/

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