Search code examples
cssmavenpluginsjbossdocbook

Custom CSS with JBoss jDocBook maven plugin


I'm trying to include custom CSS file into the HTML generated by jDocBook plugin. Here is the plugin configuration:

<plugin>
    <groupId>org.jboss.maven.plugins</groupId>
    <artifactId>maven-jdocbook-plugin</artifactId>
    <version>2.3.7</version>
    <extensions>true</extensions>
    <configuration>
        <sourceDocumentName>book.xml</sourceDocumentName>
        <imageResource>
            <directory>${basedir}/src/main/images</directory>
        </imageResource>
        <cssResource>
            <directory>${basedir}/src/main/css</directory>
        </cssResource>
        <formats>
            <format>
                <formatName>pdf</formatName>
                <stylesheetResource>classpath:/docbook/fo/docbook.xsl</stylesheetResource>
            </format>
            <format>
                <formatName>html</formatName>
                <stylesheetResource>classpath:/docbook/html/chunk.xsl</stylesheetResource>
            </format>
        </formats>
    </configuration>
</plugin>

I have a file named driver.css in my src/main/css. After build this file appears under target/docbook/publish/en-US/html alongside book.html, but it doesn't get included.

I also tried to add

<?xml-stylesheet href="driver.css" type="text/css"?>

to the book.xml, but that doesn't seem to help.

Am I missing any configuration parameters here?


Solution

  • In order to style HTML output with custom CSS one has to pass html.stylesheet=<path to css file> to the XSLT processor. To do this using JDocBook plugin, one has to add following under <configuration>:

    <configuration>
        ...
        <options>
            <transformerParameters>
                <html.stylesheet>driver.css</html.stylesheet>
            </transformerParameters>
        </options>
        ...
    </configuration>
    

    Shame it's not described in plugin documentation

    And just to be clear, xml-stylesheet thing is irrelevant