Skip to content

Files

Latest commit

e046618 · Feb 28, 2024

History

History

xml-maven-plugin

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Oct 14, 2023
Apr 22, 2019
Sep 21, 2023
Feb 28, 2024

XML Maven Plugin

Build Status Coverage Status Javadocs Released Version Snapshot Version

Introduction

The xml-maven-plugin plugin is for general tasks related to XML, XSD, and XSLT.

This plugin supports XML Schema 1.1.

Note

Note This plugin is not related to xml-maven-plugin from CodeHaus.

Goals Overview

  • xml:validate validates XML or XSD documents against schema(s) specified in the xsi:schemaLocation attribute.
  • xml:transform transforms XML documents by applying XSLT stylesheets.

Usage

xml:validate

The xml:validate goal is bound to the compile phase, and is used to validate XML documents against schema(s) specified in the xsi:schemaLocation attribute. The validator uses a SAX parser and supports XML Schema 1.1.

Example 1

Execution with includes directive.

<plugin>
  <groupId>org.openjax.xml</groupId>
  <artifactId>xml-maven-plugin</artifactId>
  <version>0.9.5</version>
  <executions>
    <execution>
      <goals>
        <goal>validate</goal>
      </goals>
      <configuration>
        <includes>
          <include>**/*.xsd</include>
          <include>**/*.xml</include>
        </includes>
      </configuration>
    </execution>
  </executions>
</plugin>

Example 2

Execution with includes and excludes directives.

<plugin>
  <groupId>org.openjax.xml</groupId>
  <artifactId>xml-maven-plugin</artifactId>
  <version>0.9.5</version>
  <executions>
    <execution>
      <goals>
        <goal>validate</goal>
      </goals>
      <configuration>
        <includes>
          <include>**/*.xml</include>
          <include>**/*.xsd</include>
        </includes>
        <excludes>
          <exclude>**/willfail.xml</exclude>
        </excludes>
      </configuration>
    </execution>
  </executions>
</plugin>

Example 3

Execution with includes, excludes, and resources directives.

<plugin>
  <groupId>org.openjax.xml</groupId>
  <artifactId>xml-maven-plugin</artifactId>
  <version>0.9.5</version>
  <executions>
    <execution>
      <goals>
        <goal>validate</goal>
      </goals>
      <configuration>
        <includes>
          <include>**/*.xml</include>
          <include>**/*.xsd</include>
        </includes>
        <excludes>
          <exclude>**/willfail.xml</exclude>
        </excludes>
        <resources>
          <resource>i-am-on-the-classpath.xml</resource>
          <resource>META-INF/maven/plugin.xml</resource>
        </resources>
      </configuration>
    </execution>
  </executions>
</plugin>

Configuration Parameters

Name Type Use Description
/skip¹ Boolean Optional Skip executioin. Default: false.
/includes¹ List Optional List of include patterns. Default: null.
/includes/includeⁿ String Optional Pattern of files to include. Default: null.
/excludes¹ List Optional List of exclude patterns. Default: null.
/excludes/excludeⁿ String Optional Pattern of files to exclude. Default: null.
/resources¹ List Optional List of resource names. Default: null.
/resources/resourceⁿ String Optional Resource name on the classpath. Default: null.

Execution Options

  1. Running Maven in offline mode (mvn -o) will cause xml:validate to silently pass validation of XML files with remote xsi:schemalocations. For these files, the validator will only test whether the file is well formed.

xml:transform

The xml:transform goal is bound to the generate-resources phase, and is used to transform XML documents with a XML Stylesheet Transformer (XSLT). The XSL Transformer supports XSLT 2.0.

Example 1

Execution with includes directive.

<plugin>
  <groupId>org.openjax.xml</groupId>
  <artifactId>xml-maven-plugin</artifactId>
  <version>0.9.5</version>
  <executions>
    <execution>
      <goals>
        <goal>transform</goal>
      </goals>
      <configuration>
        <destDir>${project.build.directory}/generated-resources</destDir>
        <rename>/\.\S+$/.txt/</rename>
        <stylesheet>src/main/resources/stylesheet.xsl</stylesheet>
        <includes>
          <include>**/*.xml</include>
        </includes>
      </configuration>
    </execution>
  </executions>
</plugin>

Configuration Parameters

Name Type Use Description
/skip¹ Boolean Optional Skip execution. Default: false.
/destDir¹ String Required Destination directory of transformed files.
/rename¹
 
String
 
Optional
 
Regex pattern to rename input file to output file:
    /<input>/<output>/ Default: null.
/includes¹ List Optional List of include directives. Default: null.
/includes/includeⁿ String Optional Pattern of files to include. Default: null.
/excludes¹ List Optional List of exclude directives. Default: null.
/excludes/excludeⁿ String Optional Pattern of files to exclude. Default: null.
/resources¹ List Optional List of resource names. Default: null.
/resources/resourceⁿ String Optional Resource name on the classpath. Default: null.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

This project is licensed under the MIT License - see the LICENSE.txt file for details.