1.5. Element transform

<transform
  stylesheet = anyURI
  cacheStylesheet = boolean : false
  file = Path
  to = Path
>
  Content: [ parameter | parameterGroup ]*
</transform>

<parameter
  name = Non empty token
>
  Content: Parameter value
</parameter>

<parameterGroup
  name = Non empty token
/>

Converts a XML file to another format using built-in XSLT engine.

Attributes:

stylesheet

Specifies which XSLT style sheet to use. If this URL is relative, it is relative to the directory containing the XXE configuration file.

The URI specified in this attribute may be also resolved using XML catalogs.

cacheStylesheet

If this attribute is specified as true, a precompiled form of the XSLT style sheet is built and then cached for subsequent uses.

It is not recommended to cache an XSLT style sheet unless this style sheet is small and used in highly interactive process commands (like in example 1 below).

file

Input file.

to

Output file.

Parameter and/or named parameterGroup child elements are used to parametrize the XSLT style sheet. Example: <parameter name="paper.type">A4</parameter>.

These parameters are described in the documentation of the XSLT style sheets:

If a transform element references a parameterGroup, this means that a parameterGroup configuration element (see Section 17, “parameterGroup” in XMLmind XML Editor - Configuration and Deployment) with the same name is defined elsewhere in this configuration file or in another configuration file. However, it is not an error to reference a parameterGroup for which the configuration element is not found.

1.5.1. Using a custom XSLT style sheet

A user can force the use of a custom style sheet of his own instead of the one normally specified in attribute stylesheet.

In order to do this, the user needs to specify a property called process_command_name.transform in any XXE configuration file. The value of this property must be the URL of the custom XSLT style sheet. (This property is typically specified in the user's customize.xxe file. See property configuration element in Section 16, “property” in XMLmind XML Editor - Configuration and Deployment.)

If a process command has several transform child elements, property process_command_name.transform specifies a style sheet for the first transform, process_command_name.transform.2 specifies a style sheet for the second transform, process_command_name.transform.3 specifies a style sheet for the third transform and so on.

Example: the process command to be customized is called docb.toPS (see XXE_install_dir/addon/config/docbook/xslMenu.incl). User has added the following property to his customize.xxe file.

<property name="docb.toPS.transform" url="true">fo_docbook.xsl</property>

Note that the URL is relative to the configuration file containing the definition of property docb.toPS.transform (here, it is relative to customize.xxe).

The custom XSLT style sheet fo_docbook.xsl contains:

<?xml version='1.0'?>
<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>

Note how the stock docbook.xsl is imported by this customized version.

Tip

In our opinion, it is almost impossible to cope with the complexity of customizing Norman Walsh's DocBook XSLT style sheets without reading this excellent book: DocBook XSL: The Complete Guide by Bob Stayton.