Thursday, 9 August 2007

Customizing the index.html generated by DITA OT

By default, the index.html file generated by the DITA Open Toolkit is pretty basic: there's no CSS referenced at all and all topicref elements are turned into bullets. I wanted to use the same CSS as for the topic files, and have header levels indented to look like a proper table of contents. I also find it strange that topicheader elements defined in your ditamap don't appear at all in the output.
Here's what I did:
  1. Edit the map2htmltoc.xsl file in the "xsl" folder of the DITA Open Toolkit.

  2. Find the line containing </head> that ends the HTML header in the generated file, and add the following line just above it:
       <link rel="stylesheet" href="myCSS.css"></link>
  3. Edit any other of the HTML tags you find spread about the place: I removed the OL tags and changed all LIs to Ps.

  4. At the bottom of the file, I added the following template to output any text in TOPICHEAD elements of the DITAMAP (navtitle attribute):
     <xsl:template match="//topichead">
    <xsl:element name="h2">
    <xsl:attribute name="class">topichead</xsl:attribute>
    <xsl:value-of select="@navtitle" />
    </xsl:element><xsl:value-of select="$newline"/>


No comments: