Releases

Releases are made available through the Central Repository.

Usage

The plugin is intended to be simple to use and also to address problems with the existing xml-maven-plugin (such as not being able to enable XIncludes in source XML documents without tweaking strange and poorly documented parameters in libraries deep within the system).

The plugin allows the specification of any number of transformations. That is, documents that will be transformed with named XSLT stylesheets and written to a given output directory and/or file. The plugin can also pass parameters to the stylesheet via the usual configuration section in the POM file. XIncludes are automatically enabled for all documents.

The plugin has a single goal, transform, which occurs in the generate-resources phase by default.

The plugin takes a transformation value as configuration data. These are specified in the plugin configuration section as is standard. A transformation consists of the following parameters:

Name Type Required Description
stylesheetFile String Required The path to the XSLT stylesheet, relative to ${project.basedir}.
documentFile String Required The path to the XML document to be processed, relative to ${project.basedir}.
outputDirectory String Required The directory in which to place the outputFile. Created if nonexistent.
outputDirectoryParameterName String Optional The name of the stylesheet parameter to which the value of outputDirectory will be passed.
outputFile String Required The file to which stylesheet output will be written, relative to the outputDirectory. Created if nonexistent.
stylesheetParameters java.util.Properties Optional A list of string key/value pairs passed verbatim to the XSLT stylesheet.

FAQ

Result-Document

My stylesheet uses result-document to create multiple output files. These are created in ${project.basedir}! How do I stop this from happening?

First, modify the stylesheet such that the names of files passed to result-document are prepended with a stylesheet parameter. Then, pass the name of this parameter in the outputDirectoryParameterName variable of the transformation given in the POM. The plugin will construct a URI based on outputDirectory and pass it to the stylesheet at runtime.

Previous versions of the plugin had programmers pass this value as an ordinary parameter in stylesheetParameters, but this caused problems with paths on Windows operating systems (paths beginning with drive letter names such as C:/ would be interpreted as URIs).

Examples

The following example processes the same file twice, writing the result to two different output directories. It also passes a parameter named io7m.structural-1_0_0.output_directory to the stylesheet in both cases. A file named out.xml will be created in both directories with the output of the stylesheet.

<project>
  ...

  <build>
    <plugins>
      <plugin>
        <groupId>com.io7m.saxon-plugin</groupId>
        <artifactId>io7m-saxon-plugin</artifactId>
        <version>1.0.0</version>

        <executions>
          <execution>
            <id>one<id>
            <goals>
              <goal>transform</goal>
            </goals>
            <configuration>
              <transformation>
                <stylesheetFile>src/main/xsl/main.xsl</stylesheetFile>
                <documentFile>src/main/xml/main.xml</documentFile>
                <outputDirectory>${project.build.directory}/xslt-output</outputDirectory>
                <outputFile>out.xml</outputFile>
                <outputDirectoryParameterName>io7m.structural-1_0_0.output_directory</outputDirectoryParameterName>
                <stylesheetParameters>
                  <property>
                    <name>colour</name>
                    <value>red</value>
                  </property>
                </stylesheetParameters>
              </transformation>
            </configuration>
          </execution>

          <execution>
            <id>two<id>
            <goals>
              <goal>transform</goal>
            </goals>
            <configuration>
              <transformation>
                <stylesheetFile>src/main/xsl/main.xsl</stylesheetFile>
                <documentFile>src/main/xml/main.xml</documentFile>
                <outputDirectory>${project.build.directory}/xslt-output2</outputDirectory>
                <outputFile>out.xml</outputFile>
                <outputDirectoryParameterName>io7m.structural-1_0_0.output_directory</outputDirectoryParameterName>
              </transformation>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  ...
</project>
      

Changes

No changelog is available.