Custom XSLT

The usage page describes the formats understood by the jDocBook Plugin. Each of those formats map to a format understood by DocBook itself, in terms of its provided XSLT. Thus, by default each format is processed by the standard DocBook XSLT for the specified format. It is possible for a user to redefine how transformations occur for a given format by specifying that a custom XSLT be used instead of the standard DocBook XSLT for that particular format in the configuration. There are two main ways to define the custom xslt that shouold be used...

file: URL

The first approach is to specify a file:// style URL. This URL could point to any valid file. For example, referring to a project-local file for XSLT processing might look like:

...
<plugin>
    ...
    <configuration>
        <formats>
            <format>
                ...
                <stylesheetResource>file:${basedir}/src/custom/xslt/mycustom.xsl</stylesheetResource>
            </format>
        </formats>
    </configuration>
</plugin>

classpath: URL

The second approach is to specify a classpath:// URL. These will be resolved against the current classpath when the plugin executes. Typically, these resources would come from a dependency (see for example). Referring to a classpath resource for XSLT processing might look like:

...
<plugin>
    ...
    <configuration>
        <formats>
            <format>
                ...
                <stylesheetResource>classpath:/myproject/mycustom.xsl</stylesheetResource>
            </format>
        </formats>
    </configuration>
</plugin>

docbook-support classpath: URL

See here for background discussion.

As a specific example of using an XSLT defined in a docbook-support package, consider the following docbook-support package distributed by the venerable Acme Corporation:

acmeskin.docbook-support/
    xslt/
        com/
            acme/
                fo.xslt

Using that would be as simple as:

<plugin>
    <groupId>org.jboss.maven.plugins</groupId>
    <artifacId>maven-jdocbook-plugin</artifactId>
    <extensions>true</extensions>
    <dependencies>
        <dependency>
            <groupId>com.acme</groupId>
            <artifactId>acmeskin</artifactId>
            <type>docbook-support</type>
        </dependency>
    </dependencies>
    <configuration>
        <formats>
            <format>
                <formatName>pdf</formatName>
                <stylesheetResource>classpath:/xslt/com/acme/fo.xslt</stylesheetResource>
            </format>
        </formats>
    </configuration>
</plugin>