Adding a <div> tag around all related links in XHTML output

Questions about XML that are not covered by the other forums should go here.
davegibbons
Posts: 3
Joined: Sat Mar 31, 2012 1:56 am

Adding a <div> tag around all related links in XHTML output

Post by davegibbons »

I need to add a div around all the related links in XHTML output. Oxygen appears to have customized the DITA toolkit in this area. Where would I add a div with an id attribute so that the div surrounds all of the related links on an XHTML page, including "previous" and "next" links?

Thank you for your help.
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: Adding a <div> tag around all related links in XHTML output

Post by sorin_ristache »

Hello,

For XHTML output you should run the DITA Map XHTML transformation. The related links are created in the template:

Code: Select all

<xsl:template match="*[contains(@class,' topic/related-links ')]" name="topic.related-links">
from the stylesheet [Oxygen-install-dir]\frameworks\dita\DITA-OT\xsl\xslhtml\rel-links.xsl. This template already contains a div element without attributes so you should add an id attribute to this div element, for example:

Code: Select all

<xsl:template match="*[contains(@class,' topic/related-links ')]" name="topic.related-links">
<div id="some_ID">
. . .
If you want to surround only the Previous Topic and Next Topic links you should modify only the template:

Code: Select all

<xsl:template name="next-prev-parent-links">
from [Oxygen-install-dir]\frameworks\dita\DITA-OT\xsl\xslhtml\rel-links.xsl. You should add the div element inside this template:

Code: Select all

<xsl:template name="next-prev-parent-links">
<div id=some_ID>

. . .

</div>
</xsl:template>

Regards,
Sorin
davegibbons
Posts: 3
Joined: Sat Mar 31, 2012 1:56 am

Re: Adding a <div> tag around all related links in XHTML output

Post by davegibbons »

Excellent, Sorin! Thank you!
Post Reply