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/xsd 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/xsd</dir>
              <systemId>src/main/xmlschema.xml</systemId>
            </validationSet>
          </validationSets>
        </configuration>
      </plugin>
      ...
    </plugins>
  </build>