Edit online

The examples in this section demonstrate how to use XSLT extension points from a DITA-OT plugin.

Edit online

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:

  1. In the DITA-OT-DIR\plugins\ folder, create a folder for this plugin (for example, com.oxygenxml.pdf.custom.codeblocks).
  2. Create a plugin.xml file (in the folder you created in step 1) that specifies the extension point and your customization stylesheet. For example:
    <plugin id="com.oxygenxml.pdf.custom.codeblocks">
      <feature extension="com.oxygenxml.pdf.css.xsl.merged2html5"
  3. Create your customization stylesheet (for example, custom_codeblocks.xsl) with the following content:
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        <xsl:template match="*[contains(@class, ' pr-d/codeblock ')]">
           <div class='zebra'>       
              <xsl:analyze-string regex="\n" select=".">
                   <div><xsl:value-of select="."/></div>
  4. Use the Run DITA-OT Integrator transformation scenario found in the DITA Map section in the Configure Transformation Scenario(s) dialog box.
  5. Create a custom CSS file with rules that style the codeblock structure. For example:
    div.zebra {
      font-family:courier, fixed, monospace;        
    div.zebra > *:nth-of-type(odd){        
      background-color: silver;
  6. Edit a DITA Map PDF - based on HTML5 & CSS transformation scenario and reference your custom CSS file (using the args.css parameter).
  7. Run the transformation scenario.