Hi,
The syntax you want is:
<xsl:attribute name="id">
<xsl:call-template
name="object.id"/>
</xsl:attribute>
The template named "object.id" is a DocBook XSL
utility template for getting the id or xml:id of the current
element.
To implement this in a customization layer, you
should copy the template named 'toc.line' from html/autotoc.xsl to your
customization layer and change it there.
Bob Stayton
Sagehill Enterprises
----- Original Message -----
From:
Tom
Dobbs
To:
Sent: Monday, June 14, 2010 2:25 PM
Subject: [docbook-apps] Adding an ID
attribute to HTML output
I'm trying to add an ID attribute to DocBook's HTML TOC generation, like
this:
<span class="sect1"><a id="Overview"
href="foo/bar/things/Overview.html">Overview</a></span>
<ul>
<li><span class="sect2"><a
id="KeyFeatures" href="foo/bar/things/KeyFeatures.html">Key
Features</a></span></li>
<li><span class="sect2"><a
id="sample"
href="applications/sample.html">Sample</a></span></li>
</ul>
...
The ID value is simply taken from the xml:id value of the respective XML
source tag
I need a nudge in the right direction. When I take a peek inside the
DocBook dragon, er, rather, collection of .xsl files, I find that
docbook-xsl-ns-1.75.1/html/autotoc.xsl in the html folder seems to be
responsible for the TOC generation. I also see that line 318* right after the
<span> nicely adds a class name to the enclosing span such that
<span class="sect1"> and so forth is written.
*<xsl:attribute name="class"><xsl:value-of
select="local-name(.)"/></xsl:attribute>
I am guessing that if I add a similar line right after the subsequent
<a>, I can get what I'm after. Something like:
<xsl:attribute name="id"><xsl:value-of
select="???"/></xsl:attribute>
But my question is, what do I add in for ???
And my other question is, is there a way to handle this in the
customization layer?
-Tom Dobbs