This task checks xml files are valid (or only well formed). The task uses the SAX2 parser implementation provided by JAXP by default (probably the one that is used by Ant itself), but one can specify any SAX1/2 parser if needed.

This task supports the use of nested xmlcatalog elements and/or nested <dtd> elements which are used to resolve DTDs and entities.


Attribute Description Required
file the file(s) you want to check. (optionally can use an embedded fileset) No
lenient if true, only check the xml document is well formed (ignored if the specified parser is as SAX1 parser) No
classname the parser to use. No
classpathref where to find the parser class. Optionally can use an embedded classpath element. No
failonerror fails on a error if set to true (defaults to true). No
warn log parser warn events. No

Nested Elements


<dtd> is used to specify different locations for DTD resolution.
Attribute Description Required
publicId Public ID of the DTD to resolve Yes
location Location of the DTD to use, which can be a file, a resource, or a URL Yes


The xmlcatalog element is used to perform Entity resolution.


<xmlvalidate file="toto.xml"/>

<xmlvalidate failonerror="no" lenient="yes" warn="yes"



  <fileset dir="src" includes="style/*.xsl"/>  



<xmlvalidate file="struts-config.xml" warn="false">

  <dtd publicId="-//Apache Software Foundation//DTD Struts Configuration 1.0//EN"



<xmlvalidate failonerror="no">

  <fileset dir="${project.dir}" includes="**/*.xml"/>

  <xmlcatalog refid="mycatalog"/>


<xmlvalidate failonerror="no">

  <fileset dir="${project.dir}" includes="**/*.xml"/>



         publicId="-//ArielPartners//DTD XML Article V1.0//EN"




Copyright © 2001-2002 Apache Software Foundation. All rights Reserved.