Re: [xsl] Dynamic numbering of lists in xslt

Subject: Re: [xsl] Dynamic numbering of lists in xslt
From: xslt.new <xslt.new@xxxxxxxxx>
Date: Wed, 10 Jan 2007 16:01:00 -0600
This does not seem to work for some reason if the <travel1> tag
without the condition is inbetween the other tags like this:

<travel1>
<location
<place>NY<place>
<time>EST</time>
</location>
  <travel2>
<location
<place>CaL<place>
<time>PST</time>
</location>
</travel2>
</travel1>

<travel1>
<location
<place>Chi<place>
<time>CST</time>
</location>
</travel1>

<travel1>
<text>Some text</text>
</travel1>

<travel1>
<location
<place>NY<place>
<time>EST</time>

</location>
</travel1>

<xsl:template match="travel1">

<xsl:choose>

<xsl:when test=".//location">
<xsl:if test=".//location/place=$place and .//location/time=$time">
<fo:list-block space-before="6pt" space-before.conditionality="retain">
     <fo:list-item>
             <fo:list-item-label end-indent="label-end()">
                     <fo:block>
               <xsl:number from="/"
count="travel1[location/time=$time and location/place=$place]"
format="1"/>
                     </fo:block>
             </fo:list-item-label>
             <fo:list-item-body start-indent="body-start()" end-indent="0pt">
                     <fo:block>
                             <xsl:apply-templates/>
                     </fo:block>
             </fo:list-item-body>
     </fo:list-item>
</fo:list-block>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<fo:list-block space-before="6pt" space-before.conditionality="retain">
     <fo:list-item>
             <fo:list-item-label end-indent="label-end()">
                     <fo:block>
               <xsl:number from="/" count="travel1[not(.//location)
or .//location/time=$time and .//location/place=$place] format="1"/>
                     </fo:block>
             </fo:list-item-label>
             <fo:list-item-body start-indent="body-start()" end-indent="0pt">
                     <fo:block>
                             <xsl:apply-templates/>
                     </fo:block>
             </fo:list-item-body>
     </fo:list-item>
</fo:list-block>

</xsl:otherwise>
</xsl:choose>
</xsl:template>

Now I get:

1. NY, EST
1. Some text
2. NY, EST

Why does the counter get reset for the <travel1> without the conditions?



On 1/10/07, David Carlisle <davidc@xxxxxxxxx> wrote:
> ok I think i spoke too fast. I forogot another condition. What if

just write your condition in xpath rather than english

count="travel1[
   not(location)
    or
    location/time=$time and location/place=$place]"/>

David

Current Thread