mirror of
https://github.com/apache/ant.git
synced 2025-05-18 14:04:48 +00:00
PR: 27092 Obtained from: Jesse Glick git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@276152 13f79535-47bb-0310-9956-ffa450edef68
179 lines
5.9 KiB
HTML
179 lines
5.9 KiB
HTML
<html>
|
|
|
|
<head>
|
|
<title>XMLValidate Task</title>
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<h2><a name="xmlvalidate">XMLValidate</a></h2>
|
|
<h3>Description</h3>
|
|
|
|
<p>This task checks that 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.</p>
|
|
|
|
<p>This task supports the use of nested
|
|
<li><a href="../CoreTypes/xmlcatalog.html"><tt><xmlcatalog></tt></a> elements</li>
|
|
<li><tt><dtd></tt> elements which are used to resolve DTDs and entities</li>
|
|
<li><tt><attribute></tt> elements which are used to set features on the parser.
|
|
These can be any number of
|
|
<a href="http://www.saxproject.org/apidoc/org/xml/sax/package-summary.html#package_description"><tt>http://xml.org/sax/features/</tt></a>
|
|
or other features that your parser may support.</li>
|
|
</p>
|
|
|
|
<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
|
|
(ignored if the specified parser is a SAX1 parser)
|
|
</td>
|
|
<td valign="top" align="center">No</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">classname</td>
|
|
<td valign="top">the parser to use.</td>
|
|
<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 <tt><classpath></tt> 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>
|
|
|
|
<h3><a name="nested">Nested Elements</a></h3>
|
|
<h4>dtd</h4>
|
|
<p>
|
|
<tt><dtd></tt> is used to specify different locations for DTD resolution.
|
|
</p>
|
|
<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>
|
|
<td valign="top">publicId</td>
|
|
<td valign="top">Public ID of the DTD to resolve</td>
|
|
<td align="center" valign="top">Yes</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">location</td>
|
|
<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>
|
|
<h4>xmlcatalog</h4>
|
|
<p>The <a href="../CoreTypes/xmlcatalog.html"><tt><xmlcatalog></tt></a>
|
|
element is used to perform entity resolution.</p>
|
|
<h4>attribute</h4>
|
|
<p>The <tt><attribute></tt> element is used to set SAX Parser features.
|
|
There can be any number of attributes set, as defined here:
|
|
<a href="http://www.saxproject.org/apidoc/org/xml/sax/package-summary.html#package_description"><tt>http://xml.org/sax/features/</tt></a>
|
|
A feature essentialy changes the mode of the parser.
|
|
</p>
|
|
<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>
|
|
<td valign="top">name</td>
|
|
<td valign="top">The name of the feature</td>
|
|
<td align="center" valign="top">Yes</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">value</td>
|
|
<td valign="top">The boolean value of the feature</td>
|
|
<td align="center" valign="top">Yes</td>
|
|
</tr>
|
|
</table>
|
|
</p>
|
|
|
|
|
|
<h3>Examples</h3>
|
|
<pre>
|
|
<xmlvalidate file="toto.xml"/>
|
|
</pre>
|
|
Validate toto.xml
|
|
<pre>
|
|
<xmlvalidate failonerror="no" lenient="yes" warn="yes"
|
|
classname="org.apache.xerces.parsers.SAXParser">
|
|
classpath="lib/xerces.jar">
|
|
<fileset dir="src" includes="style/*.xsl"/>
|
|
</xmlvalidate>
|
|
</pre>
|
|
Validate all .xsl files in src/style, but only warn if there is an error, rather than
|
|
halt the build.
|
|
<pre>
|
|
|
|
<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>
|
|
</pre>
|
|
|
|
Validate a struts configuration, using a local copy of the DTD.
|
|
<pre>
|
|
<xmlvalidate failonerror="no">
|
|
<fileset dir="${project.dir}" includes="**/*.xml"/>
|
|
<xmlcatalog refid="mycatalog"/>
|
|
</xmlvalidate>
|
|
</pre>
|
|
|
|
Scan all XML files in the project, using a predefined catalog to map URIs to local files.
|
|
<pre>
|
|
<xmlvalidate failonerror="no">
|
|
<fileset dir="${project.dir}" includes="**/*.xml"/>
|
|
<xmlcatalog>
|
|
<dtd
|
|
publicId="-//ArielPartners//DTD XML Article V1.0//EN"
|
|
location="com/arielpartners/knowledgebase/dtd/article.dtd"/>
|
|
</xmlcatalog>
|
|
</xmlvalidate>
|
|
</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"/>
|
|
<attribute name="http://xml.org/sax/features/validation" value="true"/>
|
|
<attribute name="http://apache.org/xml/features/validation/schema" value="true"/>
|
|
</xmlvalidate>
|
|
</pre>
|
|
Validate all .xml files in xml directory with the parser configured to perform schema validation. Note: The parser must support the <pre>http://apache.org/xml/features/validation/schema</pre> feature.
|
|
<br>
|
|
<hr>
|
|
<p align="center">Copyright © 2001-2002,2004 The Apache Software Foundation. All rights
|
|
Reserved.</p>
|
|
|
|
</body>
|
|
</html>
|
|
|