Fork me on GitHub

Check whether XML files matching a RelaxNG schema

The following configuration snippet would check whether all files in the directory src/main/relaxng are matching the schema src/main/schema.rng. Note that additional libraries are required to support RelaxNG validation.

<build>
  <plugins>
    ...
    <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>xml-maven-plugin</artifactId>
      <dependencies>
        <dependency>
          <groupId>com.componentcorp.xml.validation</groupId>
          <artifactId>jxvc</artifactId>
          <version>0.9.4</version>
        </dependency>
        <dependency>
          <groupId>com.componentcorp.xml.validation</groupId>
          <artifactId>relaxng</artifactId>
          <version>0.9.4</version>
        </dependency>
      </dependencies>
      <executions>
        <execution>
          <goals>
            <goal>validate</goal>
          </goals>
        </execution>
      </executions>
      <configuration>
        <validationSets>
          <validationSet>
            <dir>src/main/relaxng</dir>
            <systemId>src/main/schema.rng</systemId>
            <validating>true</validating>
            <schemaLanguage>http://relaxng.org/ns/structure/1.0</schemaLanguage>
          </validationSet>
        </validationSets>
      </configuration>
    </plugin>
    ...
  </plugins>
</build>