10. Customizing the XSLT style sheets used in the Convert Document submenu

In order to do this, you need to use a custom XSLT style sheet instead of the stock one. Of course, the custom XSLT style sheet includes the stock one, so you can concentrate on your customizations.

Once you have created your custom XSLT style sheet, you have to specify to XXE that it must use it instead on the stock one. This is done by the means of a system property having the proper name and value.

  1. Copy one of the following template files depending on which configuration you want to customize and on which format you want to generate:

    Configuration NameConvert toProcedure

    DocBook v5+

    HTML multi-page

    Copy chunk.xsl to custom/.

    HTML single page

    Copy html.xsl to custom/.

    HTML Help

    Copy htmlhelp.xsl to custom/.

    Java Help

    Copy javahelp.xsl to custom/.

    Eclipse Help

    Copy eclipse.xsl to custom/.

    RTF, WordprocessingML, OpenDocument, OOXML

    Copy fo.xsl to custom/.

    PDF, PostScript

    Copy fo.xsl to custom/.

    DocBook

    HTML multi-page

    Copy chunk.xsl to custom/.

    HTML single page

    Copy html.xsl to custom/.

    HTML Help

    Copy htmlhelp.xsl to custom/.

    Java Help

    Copy javahelp.xsl to custom/.

    Eclipse Help

    Copy eclipse.xsl to custom/.

    RTF, WordprocessingML, OpenDocument, OOXML

    Copy fo.xsl to custom/.

    PDF, PostScript

    Copy fo.xsl to custom/.

    XHTML Strict

    XHTML Transitional

    RTF, WordprocessingML, OpenDocument, OOXML

    Copy fo.xsl to custom/.

    PDF, PostScript

    Copy fo.xsl to custom/.

    For example, DocBook v5+ chunk.xsl looks like this:

    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                    xmlns:d="http://docbook.org/ns/docbook"
                    version="1.0"
                    exclude-result-prefixes="d">
    
      <xsl:import href="xxe-config:docbook5/xsl/html/chunk.xsl"/>
    
    </xsl:stylesheet>
  2. Edit this file using an XML or text editor and add one or more XSLT elements after the xsl:import element.

    DocBook html.xsl example: Use the UTF-8 encoding instead of default ISO-8859-1 when converting a DocBook document to single page HTML[10]:

    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                    version="1.0">
    
      <xsl:import href="xxe-config:docbook/xsl/html/docbook.xsl"/>
    
      <xsl:output method="html" 
                  encoding="UTF-8"
                  indent="no" 
                  saxon:character-representation="native;decimal"/>
    </xsl:stylesheet>

    DocBook fo.xsl example: add more information to the title page of book:

    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                    xmlns:fo="http://www.w3.org/1999/XSL/Format"
                    version="1.0">
    
    <xsl:import href="xxe-config:docbook/xsl/fo/docbook.xsl"/>
    
    <xsl:template match="bookinfo/author|info/author" mode="titlepage.mode">
      <fo:block>
        <xsl:call-template name="anchor"/>
        <xsl:call-template name="person.name"/>
        <xsl:if test="affiliation/orgname">
          <fo:block>
            <xsl:apply-templates select="affiliation/orgname"
                                 mode="titlepage.mode"/>
          </fo:block>
        </xsl:if>
        <xsl:if test="email|affiliation/address/email">
          <fo:block>
            <xsl:apply-templates select="(email|affiliation/address/email)[1]"/>
          </fo:block>
        </xsl:if>
      </fo:block>
    </xsl:template>
    
    </xsl:stylesheet>
  3. Add one of the following property configuration element to your custom .xxe file:

    Configuration NameConvert toProperty Configuration Element

    DocBook v5+

    HTML multi-page

    <property name="db5.toHTML.transform"
      url="true">chunk.xsl</property>
    HTML single page
    <property name="db5.toHTML1.transform" 
      url="true">html.xsl</property>
    HTML Help
    <property name="db5.toHTMLHelp.transform" 
      url="true">htmlhelp.xsl</property>
    Java Help
    <property name="db5.toJavaHelpStep1.transform" 
      url="true">javahelp.xsl</property>
    Eclipse Help
    <property name="db5.toEclipseHelp.transform" 
      url="true">eclipse.xsl</property>
    RTF, WordprocessingML, OpenDocument, OOXML
    <property name="db5.toRTF.transform" 
      url="true">fo.xsl</property>
    PDF, PostScript
    <property name="db5.toPS.transform" 
      url="true">fo.xsl</property>

    DocBook

    HTML multi-page

    <property name="docb.toHTML.transform" 
      url="true">chunk.xsl</property>
    HTML single page
    <property name="docb.toHTML1.transform" 
      url="true">html.xsl</property>
    HTML Help
    <property name="docb.toHTMLHelp.transform" 
      url="true">htmlhelp.xsl</property>
    Java Help
    <property name="docb.toJavaHelpStep1.transform" 
      url="true">javahelp.xsl</property>
    Eclipse Help
    <property name="docb.toEclipseHelp.transform" 
      url="true">eclipse.xsl</property>
    RTF, WordprocessingML, OpenDocument, OOXML
    <property name="docb.toRTF.transform" 
      url="true">fo.xsl</property>
    PDF, PostScript
    <property name="docb.toPS.transform" 
      url="true">fo.xsl</property>

    XHTML Strict

    XHTML Transitional

    RTF, WordprocessingML, OpenDocument, OOXML

    <property name="xhtml.toRTF.transform" 
      url="true">fo.xsl</property>
    PDF, PostScript
    <property name="xhtml.toPS.transform" 
      url="true">fo.xsl</property>


[10] XSLT style sheet parameter chunker.output.encoding does not work in this case.