Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XML DTD/Schema validation in Maven

How can I validate XML documents during a Maven build against a DTD or a XSD Schema?

like image 351
cetnar Avatar asked Oct 06 '09 20:10

cetnar


1 Answers

The validate goal of the xml-maven-plugin will check for well-formedness and optionally validate against a schema. The build will fail if the validation fails.

The plugin does not produce any report, what would you want in a report out of interest? information about the invalid files?

Here is an example usage:

  <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>
like image 84
Rich Seller Avatar answered Oct 26 '22 02:10

Rich Seller