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

Re: Different behaviour for the first item in a for-

Subject: Re: Different behaviour for the first item in a for-each-group
From: "Mark Wilson" <mark@xxxxxxxxxxxx>
Date: Sat, 31 Oct 2009 15:51:35 -0700
Re:  Different behaviour for the first item in a   for-
Hi Ken,
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". All the rest would not be marked "keep".


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


All help appreciated.
Mark

Listing 1:
<xsl:template name="format-article">
<xsl:for-each-group select="../Article" group-by="Title">
<xsl:sort select="Title"/>
<xsl:sort select="Year"/>
<xsl:sort select="IssueNumber" data-type="number"/>
<xsl:sort select="Page"/>
<xsl:for-each select="current-group()">
<fo:table-row>
<!-- Put the first group in a keeping row-->
<xsl:if test="position()=1">
<xsl:attribute name="keep-with-previous">always</xsl:attribute>
</xsl:if>
<!-- And all the other groups in a non-"keeping" row -->
<fo:table-cell>
<fo:block>
<xsl:choose>
<xsl:when test="parent::Item">
<xsl:call-template name="article0"/>
</xsl:when>
<xsl:when test="parent::Level1">
<xsl:call-template name="article1"/>
</xsl:when>
<xsl:when test="parent::Level2">
<xsl:call-template name="article2"/>
</xsl:when>
<xsl:when test="parent::Level3">
<xsl:call-template name="article3"/>
</xsl:when>
</xsl:choose>
<fo:block xsl:use-attribute-sets="citation">
<fo:wrapper xsl:use-attribute-sets="title">
<!--for a given title-->
<xsl:apply-templates select="Title"/>
</fo:wrapper>
<xsl:apply-templates select="Person"/>
<!--and for each citation-->
<xsl:apply-templates select="current-group()" mode="format"/>
</fo:block>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:for-each>
</xsl:for-each-group>
</xsl:template>


Input data:
<Item>
<Article>
<Title>Further observations</Title>
<IssueName>Mar/Apr</IssueName>
<Year>1999</Year>
<Page>34</Page>
<IssueNumber>2</IssueNumber>
</Article>
<Article>
<Title>Letters to the editor</Title>
<IssueName>Nov/Dec</IssueName>
<Year>2001</Year>
<Page>27</Page>
<IssueNumber>6</IssueNumber>
</Article>
<Article>
<Title>Philatelic news and views</Title>
<IssueName>Sep/Oct</IssueName>
<Year>2001</Year>
<Page>35</Page>
<IssueNumber>5</IssueNumber>
</Article>
<Article>
<Title>Philatelic news and views</Title>
<IssueName>Sep/Oct</IssueName>
<Year>2002</Year>
<Page>11</Page>
<IssueNumber>5</IssueNumber>
</Article>
<Article>
<Title>Philatelic news and views</Title>
<IssueName>Nov/Dec</IssueName>
<Year>2002</Year>
<Page>28</Page>
<IssueNumber>6</IssueNumber>
</Article>
<Article>
<Title>Philatelic news and views</Title>
<IssueName>Jan/Feb</IssueName>
<Year>2003</Year>
<Page>24</Page>
<IssueNumber>1</IssueNumber>
</Article>
<Article>
<Title>Philatelic news and views</Title>
<IssueName>Nov/Dec</IssueName>
<Year>2006</Year>
<Page>18</Page>
<IssueNumber>6</IssueNumber>
</Article>
</Item>


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.