Re: [xsl] Assistance with position-based Table of Contents (TOC)‏

Subject: Re: [xsl] Assistance with position-based Table of Contents (TOC)‏
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 22 Oct 2009 16:41:39 +0100
The spec isn't very clear but I think you just want

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
 

<xsl:template match="*">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>

<xsl:template match="title">
<title>
<xsl:number level="multiple" count="*[title]"/>
<xsl:text>: </xsl:text>
<xsl:apply-templates/>
</title>
</xsl:template>

</xsl:stylesheet>

which produces


<x>
<chapter chapnum="1">
    <title>1: Cooking with XML</title>
    <section>
        <title>1.1: XML Cookies</title>
        <sect1>
           <title>1.1.1: Snickerdoodles</title>
        </sect1>
    </section>
</chapter>

OR it could be:

<chapter chapnum="3"> 
    <title>2: Baking with XPATH</title>
    <BakeDesc> 
         <title>2.1: Crunching Number Cookies</title>
         <cookie> 
             <title>2.1.1: Lemon Cookies</title>
         </cookie>
    </BakeDesc>
</chapter>

</x>


from


<x>
<chapter chapnum="1">
    <title>Cooking with XML</title>
    <section>
        <title>XML Cookies</title>
        <sect1>
           <title>Snickerdoodles</title>
        </sect1>
    </section>
</chapter>

OR it could be:

<chapter chapnum="3"> <!-- chapter level -->
    <title>Baking with XPATH</title>
    <BakeDesc> <!-- section level -->
         <title>Crunching Number Cookies</title>
         <cookie> <!-- subsection level -->
             <title>Lemon Cookies</title>
         </cookie>
    </BakeDesc>
</chapter>

</x>


________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. 
________________________________________________________________________

Current Thread