10. Customizing the XSLT style sheets used in the Convert Document submenu
Prev | Chapter 5. Customizing an existing configuration | Next

## 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 Name | Convert to | Procedure
   --- | --- | ---
   DITA DITA Map DITA BookMap | XHTML multi-page | Copy xhtml.xsl to `custom/`.
   XHTML single page | Copy xhtml.xsl to `custom/`.
   HTML Help | Copy htmlhelp.xsl to `custom/`.
   Java Help | Copy javahelp.xsl to `custom/`.
   RTF, WordprocessingML, OpenDocument, OOXML | Copy fo.xsl to `custom/`.
   PDF, PostScript | Copy fo.xsl to `custom/`.
   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 XHTML 1.1 XHTML 5 | 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="docbook5-config: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[8]:

       <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                       version="1.0">

         <xsl:import href="docbook-config: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="docbook-config: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 Name | Convert to | Property Configuration Element
   --- | --- | ---

   DITA

   DITA Map

   DITA BookMap

   XHTML multi-page

       <property name="dita.toXHTML.transform"
         url="true">xhtml.xsl</property>

   XHTML single page

       <property name="dita.toXHTML1.transform"
         url="true">xhtml.xsl</property>

   HTML Help

       <property name="dita.toHTMLHelp.transform"
         url="true">htmlhelp.xsl</property>

   Java Help

       <property name="dita.toJavaHelpStep1.transform"
         url="true">javahelp.xsl</property>

   RTF, WordprocessingML, OpenDocument, OOXML

       <property name="dita.toRTF.transform"
         url="true">fo.xsl</property>

   PDF, PostScript

       <property name="dita.toPS.transform"
         url="true">fo.xsl</property>

   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

   XHTML 1.1

   XHTML 5

   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>

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

Prev | Up | Next
9. Parametrizing the XSLT style sheets used in the Convert Document submenu | Home | 11. Using a custom CSS style sheet to style the HTML files generated by the Convert Document submenu