The examples in this section demonstrate how to use XSLT extension points from a DITA-OT plugin.
Instead of directly adding plugins inside the embedded DITA-OT, it is highly recommended to use an external Oxygen Publishing Engine so that you will not lose any of your customizations anytime you upgrade the product in the future.
oxygen-publishing-engine.Suppose you want your codeblocks to have a particular background color for one line, and another color for the next line. One advantage of this coloring technique is that you can clearly see when text from the codeblock is wrapped.
This effect can be done by altering the HTML5 output, creating a <div>
for each line from the code block, then styling them.
To add this functionality using a DITA-OT plugin, follow these steps:
<plugin id="com.oxygenxml.pdf.custom.codeblocks">
<feature extension="com.oxygenxml.pdf.css.xsl.merged2html5"
file="custom_codeblocks.xsl"/>
</plugin><?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="3.0">
<xsl:template match="*[contains(@class, ' pr-d/codeblock ')]">
<div class='zebra'>
<xsl:analyze-string regex="\n" select=".">
<xsl:matching-substring/>
<xsl:non-matching-substring>
<div><xsl:value-of select="."/></div>
</xsl:non-matching-substring>
</xsl:analyze-string>
</div>
</xsl:template>
</xsl:stylesheet>div.zebra {
font-family:courier, fixed, monospace;
white-space:pre-wrap;
}
div.zebra > *:nth-of-type(odd){
background-color: silver;
} args.css
parameter).Suppose you want to add an attribute with a custom value inside a
<div> element.
<plugin id="com.oxygenxml.pdf.css.param">
<feature extension="com.oxygenxml.pdf.css.xsl.merged2html5.parameters" file="params.xml"/>
<feature extension="com.oxygenxml.pdf.css.xsl.merged2html5" file="custom.xsl"/>
</plugin>com.oxygenxml.pdf.css.xsl.merged2html5 extension point can also be
called from a Publishing Template.<dummy xmlns:if="ant:if">
<param name="custom-param" expression="${custom.param}" if:set="custom.param"/>
</dummy><?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="3.0">
<xsl:param name="custom-param"/>
<xsl:template match="*[contains(@class, ' topic/div ')]">
<div>
<xsl:call-template name="commonattributes"/>
<xsl:call-template name="setid"/>
<xsl:if test="$custom-param">
<xsl:attribute name="custom" select="$custom-param"/>
</xsl:if>
<xsl:apply-templates/>
</div>
</xsl:template>
</xsl:stylesheet>