[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Combining grouping and generate-id() for multilevel TO

Subject: Combining grouping and generate-id() for multilevel TOC
From: Ghostrider <ghostrider@xxxxxxxxxxx>
Date: Wed, 18 Jul 2001 10:01:46 +0200
ghostrider key
Hi,


I've been trying to generate a two-level TOC in my HTML output, entries 
linking to anchors created with a generate-id(). It works for the first, top 
level but I can't get the second level from the hierarchy in there properly...

Could someone maybe have a look if my problem is the same as the one Jeni 
solved in this message: 
http://www.biglist.com/lists/xsl-list/archives/200101/msg00149.html ? 
I can't seem to transform her templates and stuff to fit my situation (which, 
unfortunately, is the way I have to go about using XSL...).

Am I correct if I assume that I need to 
1. add a second grouping in the xsl for that second level, like I did for the 
first one, and
2. use another generate-id() to refer to all these second level groups with a 
unique anchor?

If so, how do I go about this? I'm having trouble putting the pieces together 
logically, so any help would be appreciated.

Thanks,

Armin



<--=========== desired HTML output file: first grouping by <Category 1> 
elements, then by <Category2>, both in the TOC section and in the Release 
Notes section with the actual content in it ================-->

TOC
***

Input
--- <a href="#0123456"> DPF </a>
--- IPC
Ouput
--- DPF
--- IPC

RELEASE NOTES
*************

Input
--- <a name="0123456'>DPF - Description 1<a>
--- IPC - Description 2
Ouput
--- DPF - Description 3
--- IPC - Description 4


<--=============== XML source ==========================-->

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" 
href="C:\HIGroup\XML\bugs\transform_09-07-01c.xsl"?>
<root>
	<Bugs>

		<Bug>
			<Category1>Input</Category1> <-- grouping for Category1 is OK in XSL -->
			<Category2>DPF</Category2> <-- additional (sub)grouping for Category2 is 
not OK yet -->
			<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 stylesheet ======================-->

<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="categories2" match="Bug" use="concat (Category1, ' 
',Category2)" />
<xsl:key name="calls" match="Call" use="@BugBase"/>

<xsl:template match="root">
<html>
<body>
<p>Release Notes</p>

<!-- TOC start-->

<p><b>Table of Contents</b></p>
<p>
<xsl:for-each select="//Bug[generate-id(.) = generate-id(key ('categories', 
Category1) [1] ) ]">
<a href="#{generate-id(.)}"><xsl:value-of select="Category1" /> </a>
  <br />
</xsl:for-each>

</p>

<!-- TOC end-->


<!-- Bug fix start-->

<xsl:apply-templates />

<!-- Bug fix end-->


</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><a name="{generate-id(.)}"><xsl:value-of select="Category1" /></a></b>
<div>
<xsl:for-each select="key('categories', Category1)">

<span style="color:maroon;font-size:10pt;">
<p style="font-family:verdana,arial, helvetica, sans-serif;font-weight:bold">
<a name="Type"></a></p>
<p>
<b><xsl:value-of select="Category2"/></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>
	
<!--Start: no output for Call node-->
<xsl:template match="root/Calls/Call">
</xsl:template>
<!--End: no output for Call node-->


</xsl:stylesheet>


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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.