This scenario walks through the process of creating a very simple plug-in
(com.example.print-pdf) that creates a new transformation type: print-pdf.
About this task
The print-pdf transformation has the following characteristics:
Uses A4 paper
Renders figures with a title at the top and a description at the bottom
Use em dashes as the symbols for unordered lists
Procedure
In the plugins directory, create a directory named
com.example.print-pdf.
In the new com.example.print-pdf directory, create a plug-in configuration file
(plugin.xml) that declares the new print-pdf transformation and its
dependencies.
Create the cfg/fo/xsl/custom.xsl file, and add XSLT overrides to it.
For example, the following code changes the rendering of <figure> elements.Figure 5. cfg/fo/xsl/custom.xsl file
<?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"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
version="2.0">
<!-- Move figure title to top and description to bottom -->
<xsl:template match="*[contains(@class,' topic/fig ')]">
<fo:block xsl:use-attribute-sets="fig">
<xsl:call-template name="commonattributes"/>
<xsl:if test="not(@id)">
<xsl:attribute name="id">
<xsl:call-template name="get-id"/>
</xsl:attribute>
</xsl:if>
<xsl:apply-templates select="*[contains(@class,' topic/title ')]"/>
<xsl:apply-templates select="*[not(contains(@class,' topic/title ') or contains(@class,' topic/desc '))]"/>
<xsl:apply-templates select="*[contains(@class,' topic/desc ')]"/>
</fo:block>
</xsl:template>
</xsl:stylesheet>
Create an English-language variable-definition file (cfg/common/vars/en.xml) and make
any necessary modifications to it.
For example, the following code removes the period after the number for an ordered-list item; it also
specifies that the bullet for an unordered list item should be an em dash.Figure 6. cfg/common/vars/en.xml file
<?xml version="1.0" encoding="UTF-8"?>
<vars xmlns="http://www.idiominc.com/opentopic/vars">
<!-- Remove dot from list number -->
<variable id="Ordered List Number"><param ref-name="number"/></variable>
<!-- Change unordered list bullet to an em dash -->
<variable id="Unordered List bullet">—</variable>
</vars>
Results
The new plug-in directory has the following layout and files: