summaryrefslogtreecommitdiff
path: root/docs/manual/OptionalTasks/xmlvalidate.html
blob: 65551f3b551ded751c1e707a0d3be5e8ba8a1fed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<html>

<head>
<title>XMLValidate Task</title>
</head>

<body>

<h2><a name="xmlvalidate">XMLValidate</a></h2>
<h3>Description</h3>

<p>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.</p>

<p>This task supports the use of nested <a
href="../CoreTypes/xmlcatalog.html">xmlcatalog</a> elements and/or nested
<tt>&lt;dtd&gt;</tt> elements which are used to resolve DTDs and entities.</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 as 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 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>

<h3><a name="nested">Nested Elements</a></h3>
<h4>dtd</h4>
&lt;dtd&gt; is used to specify different locations for DTD resolution.
<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">xmlcatalog</a>
element is used to perform Entity resolution.</p>


<h3>Examples</h3>
<blockquote><pre>
&lt;xmlvalidate file="toto.xml"/&gt;

&lt;xmlvalidate failonerror="no" lenient="yes" warn="yes"
             classname="org.apache.xerces.parsers.SAXParser" &gt;
             classpath="lib/xerces.jar"&gt;
  &lt;fileset dir="src" includes="style/*.xsl"/&gt;
&lt;/xmlvalidate&gt;

&lt;xmlvalidate file="struts-config.xml" warn="false"&gt;
  &lt;dtd publicId="-//Apache Software Foundation//DTD Struts Configuration 1.0//EN"
       location="struts-config_1_0.dtd"/&gt;
&lt;/xmlvalidate&gt;

&lt;xmlvalidate failonerror="no"&gt;
  &lt;fileset dir="${project.dir}" includes="**/*.xml"/&gt;
  &lt;xmlcatalog refid="mycatalog"/&gt;
&lt;/xmlvalidate&gt;

&lt;xmlvalidate failonerror="no"&gt;
  &lt;fileset dir="${project.dir}" includes="**/*.xml"/&gt;
  &lt;xmlcatalog&gt;
       &lt;dtd
         publicId=&quot;-//ArielPartners//DTD XML Article V1.0//EN&quot;
         location=&quot;com/arielpartners/knowledgebase/dtd/article.dtd&quot;/&gt;
  &lt;/xmlcatalog&gt;
&lt;/xmlvalidate&gt;
</pre></blockquote>
<hr>

<p align="center">Copyright &copy; 2001-2002 Apache Software Foundation. All rights
Reserved.</p>

</body>
</html>