Fork me on GitHub

Checking whether XML files are matching an XML Schema

The following configuration snippet would check, whether all files in the directory src/main/xml are matching the schema src/main/xmlschema.xsd.

  <build>
    <plugins>
      ...
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>xml-maven-plugin</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>validate</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <validationSets>
            <validationSet>
              <dir>src/main/xml</dir>
              <systemId>src/main/xmlschema.xsd</systemId>
            </validationSet>
          </validationSets>
        </configuration>
      </plugin>
      ...
    </plugins>
  </build>