This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Generating a Table of Contents linked to grouped nodesets???
- To: xsl-list at lists dot mulberrytech dot com
- Subject: [xsl] Generating a Table of Contents linked to grouped nodesets???
- From: ghostrider <ghostrider at advalvas dot be>
- Date: Thu, 12 Jul 2001 14:12:52 +0200
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hi all,
I'm having troubling generating a linked Table of Contents with XSL...
My XSL file groups and outputs a number of nodes to HTML, like this:
Input
--DPF: Description1
--IPC: Description2
--...
Output
--DPF: Description3
--123: Description4
--abc
...
Tooling
--DPF: Description5
--123: Description6
---...
...
I would like to have a small table of contents dynamically generated, and
output in the same HTML file, just before the individual nodes and elements
are processed and grouped as above.
My TOC should simply be something like this:
Contents
--------
Input <link to the DIV containing all input nodesets as above)
Output
Tooling
....
I have to create some sort of unique bookmark in the HTML code for each TOC
entry to link to. Any suggestions on how to do this?
[I'll include the XML and XSL files below]
Thanks,
Armin
** XML file ***
<?xml-stylesheet type="text/xsl"
href="C:\HIGroup\XML\bugs\transform_09-07-01c.xsl"?>
<root>
<Bugs>
<Bug>
<Category1>Input</Category1>
<Category2>DPF</Category2>
<Type>Bug fix</Type>
<Description>Reading in ODB++ somehow ...</Description>
<BugBase>001</BugBase>
</Bug>
<Bug>
<Category1>Input</Category1>
<Category2>IPC</Category2>
<Type>Enhancement</Type>
<Description>Reading in ODB++ somehow ...</Description>
<BugBase>002</BugBase>
</Bug>
<Bug>
<Category1>Output</Category1>
<Category2>IPC</Category2>
<Type>Enhancement</Type>
<Description>Reading in ODB++ somehow ...</Description>
<BugBase>003</BugBase>
</Bug>
</Bugs>
<Calls>
<Call BugBase="001"> B10015 </Call>
<Call BugBase="001"> B10016 </Call>
<Call BugBase="002"> B10017 </Call>
<Call BugBase="003"> B10018 </Call>
<Call BugBase="003"> B10019 </Call>
</Calls>
</root>
** XSL **
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:key name="categories" match="Bug" use="Category1"/>
<xsl:key name="calls" match="Call" use="@BugBase"/>
<xsl:template match="root">
<html>
<body>
<p>Release Notes</a>
</p>
<xsl:apply-templates />
</body>
</html>
</xsl:template>
<xsl:template match="root/Bugs">
<xsl:apply-templates select="Bug[generate-id(.) = generate-id(key
('categories', Category1) [1] ) ]" />
</xsl:template>
<xsl:template match="Bugs/Bug">
<div><b><xsl:value-of select="Category1" /></b><div>
<xsl:for-each select="key('categories', Category1)">
<span><b><xsl:value-of select="Category2"/> (<xsl:value-of
select="Type"/>)</b></p>
</span>
<div>
<p><xsl:for-each select="key('calls', BugBase)">
<xsl:value-of select="."/>
<xsl:if test="position() != last()">, </xsl:if>
</xsl:for-each></p>
<div>
<p><xsl:value-of select="Description"/>
</p>
</div>
</div>
</xsl:for-each>
</div> </div>
</xsl:template>
</xsl:stylesheet>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list