Maven artifacts containing the XSL Stylesheets.

Description

The namespaced stylesheets (used for docbook 5) can be used with:

<dependencies>
    <dependency>
      <groupId>net.sf.docbook</groupId>
      <artifactId>docbook-xsl</artifactId>
      <version>1.75.1</version>
      <type>zip</type>
      <classifier>ns-resources</classifier>
    </dependency>
</dependencies>

The non namespaced stylesheets can be used with:

<dependencies>
    <dependency>
      <groupId>net.sf.docbook</groupId>
      <artifactId>docbook-xsl</artifactId>
      <version>1.75.1</version>
      <type>zip</type>
      <classifier>resources</classifier>
    </dependency>
</dependencies>

Both artifacts contain most of the content of the regular docbook releases you can download except that the root directory is docbook/ for ease of version migration. Here is the content of docbook/ of this artifact:

<DIR>          common
<DIR>          eclipse
<DIR>          epub
<DIR>          fo
<DIR>          highlighting
<DIR>          html
<DIR>          htmlhelp
<DIR>          javahelp
<DIR>          lib
<DIR>          images
<DIR>          manpages
<DIR>          params
<DIR>          profiling
<DIR>          roundtrip
<DIR>          slides
<DIR>          template
<DIR>          tests
<DIR>          website
<DIR>          xhtml
<DIR>          xhtml-1_1
         2 305 .CatalogManager.properties.example
            54 .urilist
           143 AUTHORS
           578 BUGS
           609 catalog.xml
         1 960 COPYING
         3 375 INSTALL
        28 701 install.sh
         3 646 Makefile
         2 239 NEWS
         6 087 NEWS.html
         3 790 NEWS.xml
         5 809 README
       655 338 RELEASE-NOTES.html
     1 089 899 RELEASE-NOTES.pdf
       287 610 RELEASE-NOTES.txt
       481 195 RELEASE-NOTES.xml
           679 TODO
         4 510 VERSION

Common usage

A common usage of these artifacts is extracting them in a temporary directory, this can be done as the following:

<plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <id>unpack-shared-resources</id>
            <goals>
              <goal>unpack-dependencies</goal>
            </goals>
            <!-- linked with generate-resources phase -->
            <phase>generate-resources</phase>
            <configuration>
              <outputDirectory>${project.build.directory}/generated-resources</outputDirectory>
              <includeGroupIds>net.sf.docbook</includeGroupIds>
              <includeArtifactIds>docbook-xsl</includeArtifactIds>
              <includeClassifiers>ns-resources</includeClassifiers>
              <excludeTransitive>true</excludeTransitive>
            </configuration>
          </execution>
        </executions>
</plugin>

And use an xslt engine plugin, this can be done as the following:

          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>xml-maven-plugin</artifactId>
            <version>1.0-beta-2</version>
            <executions>
              <execution>
                <goals>
                  <goal>transform</goal>
                </goals>
                <!-- linked with generate-resources phase -->
                <phase>generate-resources</phase>
              </execution>
            </executions>
            <configuration>

              <!-- transformationSets are used for the goal transform -->
              <transformationSets>
                <transformationSet>
                  <!-- select the xml files to transform using dir and includes -->
                  <dir>src/main/docbook/</dir>
                  <includes>
                    <include>sample.xml</include>
                  </includes>
                  <!-- the stylesheet is located in the previously extracted directory under the docbook/ directory -->
                  <stylesheet>${project.build.directory}/generated-resources/docbook/html/docbook.xsl</stylesheet>
                  <!-- rename the file with a proper extension -->
                  <fileMappers>
                    <fileMapper implementation="org.codehaus.plexus.components.io.filemappers.FileExtensionMapper">
                      <targetExtension>.html</targetExtension>
                    </fileMapper>
                  </fileMappers>
                  <!-- specify the transformed file directory -->
                  <outputDir>${project.build.directory}/docbook</outputDir>
                  <!-- set some stylesheet parameters -->
                  <parameters>
                    <parameter>
                      <name>draft.mode</name>
                      <value>yes</value>
                    </parameter>
                  </parameters>
                </transformationSet>
              </transformationSets>
            </configuration>
            <dependencies>
              <dependency>
                <groupId>net.sf.docbook</groupId>
                <artifactId>docbook-xsl-saxon</artifactId>
                <version>1.0.0</version>
              </dependency>
            </dependencies>
          </plugin>

A complete example can be find in the svn at http://docbook.svn.sourceforge.net/viewvc/docbook/trunk/maven/docbook-sample/

MavenDocBookXSL (last edited 2011-03-17 13:10:26 by NormanWalsh)