2001-04-10 04:47:00 +00:00
< html >
< head >
< title > XMLValidate Task< / title >
< / head >
< body >
< h2 > < a name = "xmlvalidate" > XMLValidate< / a > < / h2 >
< h3 > Description< / h3 >
2002-04-22 08:56:13 +00:00
2002-09-09 02:50:35 +00:00
< p > This task checks XML files are valid (or only well formed). The
2002-04-22 08:56:13 +00:00
task uses the SAX2 parser implementation provided by JAXP by default
2002-09-09 02:50:35 +00:00
(usually the one that is used by Ant itself), but one can specify any
SAX1/2 parser if needed. Ant ships with Xerces, which is also what is built in
to Java 1.4: XML parsers built into the runtime override Ant's choice.< / p >
2001-04-10 04:47:00 +00:00
2002-09-09 02:50:35 +00:00
< p > This task supports the use of nested
< li / > < a href = "../CoreTypes/xmlcatalog.html" > < tt > < xmlcatalog> < / tt > < / a > elements
< li / > < tt > < dtd> < / tt > elements which are used to resolve DTDs and other entities.
< li / > < tt > < feature> < / tt > elements which are used to set features. These can be any number of < a href = "http://www.saxproject.org/apidoc/org/xml/sax/package-summary.html#package_description" > http://xml.org/sax/features/< / a >
< / p >
2002-06-01 12:26:43 +00:00
2001-04-10 04:47:00 +00:00
< h3 > Parameters< / h3 >
< table border = "1" cellpadding = "2" cellspacing = "0" >
< tr >
< td valign = "top" > < b > Attribute< / b > < / td >
< td valign = "top" > < b > Description< / b > < / td >
< td align = "center" valign = "top" > < b > Required< / b > < / td >
< / tr >
< tr >
< td valign = "top" > file< / td >
< td valign = "top" > the file(s) you want to check. (optionally can use an embedded fileset)< / td >
< td valign = "top" align = "center" > No< / td >
< / tr >
< tr >
< td valign = "top" > lenient< / td >
< td valign = "top" >
if true, only check the xml document is well formed
2002-07-09 21:06:15 +00:00
(ignored if the specified parser is as SAX1 parser)
2001-04-10 04:47:00 +00:00
< / td >
< td valign = "top" align = "center" > No< / td >
< / tr >
< tr >
< td valign = "top" > classname< / td >
2002-04-22 08:56:13 +00:00
< td valign = "top" > the parser to use.< / td >
2001-04-10 04:47:00 +00:00
< td align = "center" valign = "top" > No< / td >
< / tr >
< tr >
< td valign = "top" > classpathref< / td >
< td valign = "top" > where to find the parser class. Optionally can use an embedded classpath element.< / td >
< td align = "center" valign = "top" > No< / td >
< / tr >
< tr >
< td valign = "top" > failonerror< / td >
< td valign = "top" > fails on a error if set to true (defaults to true).< / td >
< td align = "center" valign = "top" > No< / td >
< / tr >
< tr >
< td valign = "top" > warn< / td >
< td valign = "top" > log parser warn events.< / td >
< td align = "center" valign = "top" > No< / td >
< / tr >
< / table >
2002-01-19 21:19:42 +00:00
< h3 > < a name = "nested" > Nested Elements< / a > < / h3 >
< h4 > dtd< / h4 >
2002-09-09 02:50:35 +00:00
< dtd> is used to specify different locations for DTD and entity resolution.
2002-01-19 21:19:42 +00:00
< table border = "1" cellpadding = "2" cellspacing = "0" >
< tr >
< td width = "12%" valign = "top" > < b > Attribute< / b > < / td >
< td width = "78%" valign = "top" > < b > Description< / b > < / td >
< td width = "10%" valign = "top" > < b > Required< / b > < / td >
< / tr >
< tr >
2002-07-09 21:06:15 +00:00
< td valign = "top" > publicId< / td >
2002-01-19 21:19:42 +00:00
< td valign = "top" > Public ID of the DTD to resolve< / td >
< td align = "center" valign = "top" > Yes< / td >
< / tr >
< tr >
2002-07-09 21:06:15 +00:00
< td valign = "top" > location< / td >
2002-01-19 21:19:42 +00:00
< td valign = "top" > Location of the DTD to use, which can be a file,
a resource, or a URL< / td >
< td align = "center" valign = "top" > Yes< / td >
< / tr >
< / table >
2002-06-01 12:26:43 +00:00
< h4 > xmlcatalog< / h4 >
2002-07-09 21:06:15 +00:00
< p > The < a href = "../CoreTypes/xmlcatalog.html" > xmlcatalog< / a >
2002-06-01 12:26:43 +00:00
element is used to perform Entity resolution.< / p >
2002-09-09 02:50:35 +00:00
< h4 > feature< / h4 >
< p > The feature element is used to set SAX Parser features.
A feature essentialy changes the mode of the parser.
There can be an arbitrary amount of features set as defined here:
< a href = "http://www.saxproject.org/apidoc/org/xml/sax/package-summary.html#package_description" > http://xml.org/sax/features/< / a >
< / p >
2002-01-19 21:19:42 +00:00
2001-04-10 04:47:00 +00:00
< h3 > Examples< / h3 >
2002-09-09 02:50:35 +00:00
< pre >
2001-04-10 04:47:00 +00:00
< xmlvalidate file="toto.xml"/>
2002-01-19 21:19:42 +00:00
< xmlvalidate failonerror="no" lenient="yes" warn="yes"
2002-09-04 11:05:19 +00:00
classname="org.apache.xerces.parsers.SAXParser">
2002-01-19 21:19:42 +00:00
classpath="lib/xerces.jar">
2002-07-09 21:06:15 +00:00
< fileset dir="src" includes="style/*.xsl"/>
2002-01-19 21:19:42 +00:00
< /xmlvalidate>
2002-09-09 02:50:35 +00:00
< / pre >
Validate all .xsl files in src/style, but only warn if there is an error, rather than
halt the build.
2002-07-09 21:06:15 +00:00
2002-09-09 02:50:35 +00:00
< pre >
2002-01-19 21:19:42 +00:00
< xmlvalidate file="struts-config.xml" warn="false">
< dtd publicId="-//Apache Software Foundation//DTD Struts Configuration 1.0//EN"
location="struts-config_1_0.dtd"/>
< /xmlvalidate>
2002-09-09 02:50:35 +00:00
< / pre >
Validate a struts configuration, using a local copy of the DTD.
< pre >
2002-06-01 12:26:43 +00:00
< xmlvalidate failonerror="no">
< fileset dir="${project.dir}" includes="**/*.xml"/>
< xmlcatalog refid="mycatalog"/>
< /xmlvalidate>
2002-09-09 02:50:35 +00:00
< / pre >
Scan all XML files in the project, using a predefined catalog to map URIs to local files.
< pre >
2002-06-01 12:26:43 +00:00
< xmlvalidate failonerror="no">
< fileset dir="${project.dir}" includes="**/*.xml"/>
< xmlcatalog>
2002-07-09 21:06:15 +00:00
< dtd
2002-06-01 12:26:43 +00:00
publicId=" -//ArielPartners//DTD XML Article V1.0//EN"
location=" com/arielpartners/knowledgebase/dtd/article.dtd" />
< /xmlcatalog>
< /xmlvalidate>
2002-09-09 02:50:35 +00:00
< / pre >
Scan all XML files in the project, using the catalog defined inline.
< pre >
< xmlvalidate failonerror="yes" lenient="no" warn="yes">
< fileset dir="xml" includes="**/*.xml"/>
< feature name="http://xml.org/sax/features/validation" value="true"/>
< feature name="http://apache.org/xml/features/validation/schema" value="true"/>
< /xmlvalidate>
< / pre >
Validate the XML files using XML Schema validation.
2001-04-10 04:47:00 +00:00
< hr >
2002-01-19 21:19:42 +00:00
< p align = "center" > Copyright © 2001-2002 Apache Software Foundation. All rights
2001-04-10 04:47:00 +00:00
Reserved.< / p >
< / body >
< / html >