Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] Different behaviour for the first item in a for-each-group

From: "G. Ken Holman" <gkholman@----------------.--->
To: <xsl-list@-----.------------.--->
Date: 11/1/2009 1:57:00 AM
At 2009-10-31 15:51 -0700, Mark Wilson wrote:
>I was not careful in the way I described this problem. Each group 
>consists of a single title with one or more citations. What I must 
>have said is that I wanted to set the Title in each group to "keep". 
>What I *should* have said was, I want to set the only the first 
>group to "keep". For the input data at the end of this email, that 
>would be the title "Further observations".

Is it a co-incidence that it is alphabetically the first and 
positioned as first?  I'm assuming because of your use of <xsl:sort> 
that the alphabetical order is important in the determination of first.

>All the rest would not be marked "keep".

Then I would have worded your request "the first of the sorted 
population" not "the first of the group".

>Clearly, I do not want (from listing 1):
>                    <xsl:if test="position()=1">
>                        <xsl:attribute 
> name="keep-with-previous">always</xsl:attribute>
>                    </xsl:if>

It wasn't clear to me because you were grouping articles and asked 
for the first of the group.  I believe Martin interpreted it the same way.

I now understand you were grouping the population of articles and 
need a keep on the first of the sorted population.

>However, I do not know XPath well. How do I select only the first 
>group for marking and let the other groups pass without marking them?

   <xsl:for-each-group select="...population...">
     <xsl:sort .../>
     <xsl:sort .../>
     <xsl:sort .../>
     <xsl:variable name="group-position" select="position()"/>
     <xsl:for-each select="current-group()">
        <fo:table-row>
           <xsl:if test="position()=1 and $group-position=1">
              <!--then at the very first of the sorted population-->
              <xsl:attribute name="keep-with-previous">.....

I hope this helps.

. . . . . . . . . . . . . Ken


--
Upcoming:  hands-on XSLT, XQuery and XSL-FO Washington DC Nov 2009
Interested in other classes?  http://www.CraneSoftwrights.com/s/i/
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
Video lesson:    http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18
Video overview:  http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18
G. Ken Holman                 mailto:gkholman@C...
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal


--~------------------------------------------------------------------
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@l...>
--~--



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