XSLT Table of Contens

walexand

Usenet Archive
Joined
Aug 9, 2004
Messages
3
Reaction score
0
Can someone help me! I'am trying to develope a XSTL that make me automatic a "Table of Centens" from a XML Document.

my XLM File looks like this:
<section>
<title>Index1</title>
</section>
<section>
<title>Index2</title>
<section>
<title>Index21</title>
<section>
<title>Index211</title>
</section>
</section>
<section>
<title>Index22</title>
</section>
</section>
<section>
<title>Index3</title>
</section>

And a want to get this output:
<h2>Toc<h2>
<ol>
<li>Index1 </li>
<li>Index2
<ol>
<li>Index21
<ol>
<li>Index211</li>
</ol>
</li>
<li>Index22</li>
</ol>
</li>
<li>Index3</li>
</ol>

Alexander W.
 
Joined
Aug 9, 2004
Messages
14
Reaction score
0
a écrit :
Can someone help me! I'am trying to develope a XSTL that make me automatic a "Table of Centens" from a XML Document.

This should do it :

<xsl:template match="/">
<h2>Toc</h2>
<ol>
<xsl:apply-templates />
</ol>
</xsl:template>

<xsl:template match="section">
<li><xsl:apply-templates select="title" />
<xsl:if test="count(section)&gt;0">
<ol>
<xsl:apply-templates select="section"/>
</ol>
</xsl:if>
</li>
</xsl:template>

A good entry point about XSLT :
http://www.zvon.org/xxl/XSLTutorial/Output/index.html

Hth
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
548,208
Messages
3,104,799
Members
249,594
Latest member
henrywalsh

Latest Threads

Top