Customizing the Built-In DITA XSLT Output
The included DITA stylesheet modules follow some conventions that enable simple,
straghtforward customization.
The built-in DITA XSLT stylesheet uses a common pattern for all elements, enabling simple customization using custom template modes.
html-tag-name
- Use this mode to specify the HTML element
name.
<xsl:template match="&topic;/&topic;//&topic;/&title;" mode="html-tag-name"> <xsl:text>h4</xsl:text> </xsl:template>
html-atts
- Use this mode to specify additional attributes to be placed on the HTML element for
the
tag.
<xsl:template match="¬e;" mode="html-atts"> <xsl:attribute name="data-note-type" select="@type"/> </xsl:template>
output-class
- Use this mode to contribute tokens to the HTML @class attribute on the
generated HTML element. It's generally a good idea to end such a template with
<xsl:next-match/>
to ensure all contributions to @class are processed.<xsl:template match="&tm;" mode="output-class"> <xsl:value-of select="@tmtype"/> <xsl:next-match/> </xsl:template>
Note: By default, all element names in the specialization hierarchy are automatically included in the HTML @class attribute. For example, the @class attribute for <xmlelement>, which is specialized from <markupname> and <keyword>, isclass="keyword markupname xmlelement"
. In addition, the @outputclass values also appended to the HTML @class. gentext-before-outer
gentext-before-inner
gentext-after-inner
gentext-after-outer
- These modes enable you to easily insert content before and/or after an element's
content. The
inner
variants will place the generated code inside the wrapper element; theouter
variations, outside the wrapping elements. When using this mode, it's best practice to end with<xsl:next-match/>
to ensure that all generated text is processed.<xsl:template match="&q;" mode="gentext-before-inner gentext-after-inner"> <xsl:text>"</xsl:text> <xsl:next-match/> </xsl:template>