tags:

views:

16

answers:

1

I'm trying to validate my XML resources during maven build cycle. Is there any plugin for this purpose, or I should use ant + xmllint manually?

+2  A: 

If you just have to validate XML files then you can use the Maven XML Plugin.

The following example would check all files in the directory "xml" for well formedness. Additionally, it would validate all files in the directory "xsd" against the schema "xmlschema.xml".

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