Hi All, I am new at
XML and XSL and I am trying to build a simple TOC.
this is what I have so far: Any help would be great.
XML:
- Code: Select all
<?xml version="1.0" encoding="UTF-8" ?>
-
<Title />
- <Sec1>
<Title>Section 1</Title>
</Sec1>
- <Sec1>
<Title>Section 2</Title>
</Sec1>
</Chapter>
<booktitle>test</booktitle>
</Book>
XSL File:
- Code: Select all
<?xml version="1.0" encoding="ISO-8859-1" ?>
f(clean);
- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
- <xsl:template match="/">
- <html>
- <body>
<h3>TOC</h3>
- <ul>
- <xsl:for-each select="Chapter/Sec1">
- <li>
- <a href="#{generate-id(Sec1)}">
<xsl:value-of select="title" />
</a>
</li>
</xsl:for-each>
</ul>
<hr />
- <xsl:for-each select="Chapter/Sec1">
Chapter:
- <a name="{generate-id(title)}">
<xsl:value-of select="title" />
</a>
<br />
Title:
<xsl:value-of select="title" />
<hr />
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>