[xsl] TOC despair

Subject: [xsl] TOC despair
From: Gustaf Liljegren <gustaf.liljegren@xxxxxxxxxxxx>
Date: Thu, 04 Dec 2003 00:42:39 +0100
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>

Thanks,

Gustaf



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


Current Thread