Re: [docbook-apps] Adding an ID attribute to HTML output

From
Bob Stayton <>
Date
2010-06-15T17:32:40+00:00
ID
03e401cb0cb0$b9b86d00$6600a8c0@pazu
Thread
Re: [docbook-apps] Adding an ID attribute to HTML output
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