RE: [xsl] TOC despair

Subject: RE: [xsl] TOC despair
From: "Christopher Hearns" <chearns@xxxxxxxxxx>
Date: Wed, 3 Dec 2003 19:16:52 -0500
Woops. Blasted Outlook.

Actually, I'm not sure how you're doing this, but I thought the attribute tag had to be located before the content, which means that in my example of the order of the elephants being reversed, you will let your break before the word Serengeti. So you'll have to test for children as well (since you don't want the break after the parent if the last section has children), and for children you'll have to test whether or not their parent is last, and whether or not they are last.

christopher hearns, Esq.
let me touch your perfect body with my mind
http://www.countplusplus.ca


-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Binkley,
Peter
Sent: Wednesday, December 03, 2003 18:50
To: 'xsl-list@xxxxxxxxxxxxxxxxxxxxxx'
Subject: RE: [xsl] TOC despair


How about test="position() = last()" in the "section" template? You might
also need to test whether the parent is a chapter instead of another
section.

Peter


> -----Original Message-----
> From: Gustaf Liljegren [mailto:gustaf.liljegren@xxxxxxxxxxxx] 
> Sent: Wednesday, December 03, 2003 4:43 PM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] TOC despair
> 
> 
> This shouldn't be hard, but I can't get it right. I'll try to 
> give enough info. The XML structure looks something like this:
> 
> <book>
>   <chapter>
>     <section>
>       <section/>
>     </section>
>   </chapter>
> </book>
> 
> One section may contain other sections an so on. The problem 
> is in the TOC generation, where I want a little space after 
> each chapter, like so:
> 
> Chapter 1: Elephants....................2  <-- chapter
> African Elephants.......................2  <-- chapter/section
>   Serengeti.............................3  <-- 
> chapter/section/section Indian 
> Elephants........................4  <-- chapter/section
>                                            <-- space here, 
> please Chapter 2: Tigers.......................5
> 
> How do I say in XPath "the last section in this chapter"? 
> Here's my try, that won't work:
> 
> <xsl:template match="section" mode="toc">
>   ...
>   <xsl:if test="count(following::section) = 0">
>     <xsl:attribute name="margin-bottom">1em</xsl:attribute>
>   </xsl:if>
>   ...
> </xsl:template>

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


Current Thread