source: other-projects/trunk/realistic-books/packages/AntInstaller/web/manual1.7.0/manual/OptionalTasks/schemavalidate.html@ 19253

Last change on this file since 19253 was 19253, checked in by davidb, 15 years ago

Establishing a source code repository for Veronica's Realistic Book's software

File size: 9.4 KB
Line 
1<!--
2 Licensed to the Apache Software Foundation (ASF) under one or more
3 contributor license agreements. See the NOTICE file distributed with
4 this work for additional information regarding copyright ownership.
5 The ASF licenses this file to You under the Apache License, Version 2.0
6 (the "License"); you may not use this file except in compliance with
7 the License. You may obtain a copy of the License at
8
9 http://www.apache.org/licenses/LICENSE-2.0
10
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16-->
17<html>
18
19<head>
20<link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
21<title>SchemaValidate Task</title>
22</head>
23
24<body>
25
26<h2><a name="schemavalidate">SchemaValidate</a></h2>
27<h3>Description</h3>
28
29<p>This task validates XML files described by an XML Schema.
30The task extends the XmlValidate task with XSD-specific features.</p>
31<ol>
32<li>The parser is created validating and namespace aware
33</li>
34<li>Validation is turned on.</li>
35<li>Schema validation is turned on.</li>
36<li>Any no-namespace schema URL or file supplied is used as the no-namespace schema
37<li>All nested schema declarations are turned into the list of namespace-url
38bindings for schema lookup.
39</ol>
40
41Note that nested catalogs are still used for lookup of the URLs given as the
42sources of schema documents, so you can still delegate lookup to a catalog, you
43just need to list all schema URIs and their URL equivalents.
44
45<p>This task supports the use of nested
46 <li><a href="../CoreTypes/xmlcatalog.html"><tt>&lt;xmlcatalog&gt;</tt></a> elements</li>
47 <li> <tt>&lt;schema&gt;</tt> elements, that bind a namespace URI to a URL or a
48 local filename.
49 <li><tt>&lt;dtd&gt;</tt> elements which are used to resolve DTDs and entities.</li>
50 <li><tt>&lt;attribute&gt;</tt> elements which are used to set features on the parser.
51 These can be any number of
52 <a href="http://www.saxproject.org/apidoc/org/xml/sax/package-summary.html#package_description"><tt>http://xml.org/sax/features/</tt></a>
53 or other features that your parser may support.</li>
54 <li><tt>&lt;property&gt;</tt> elements, containing string properties
55</p>
56
57<p>
58The task only supports SAX2 or later parsers: it is an error to specify a SAX1
59parser.
60
61
62<h3>Parameters</h3>
63<table border="1" cellpadding="2" cellspacing="0">
64 <tr>
65 <td valign="top"><b>Attribute</b></td>
66 <td valign="top"><b>Description</b></td>
67 <td align="center" valign="top"><b>Required</b></td>
68 </tr>
69 <tr>
70 <td valign="top">classname</td>
71 <td valign="top">the parser to use.</td>
72 <td align="center" valign="top">No</td>
73 </tr>
74 <tr>
75 <td valign="top">classpathref</td>
76 <td valign="top">where to find the parser class.
77 Optionally can use an embedded <tt>&lt;classpath&gt;</tt> element.</td>
78 <td align="center" valign="top">No</td>
79 </tr>
80 <tr>
81 <td valign="top">disableDTD</td>
82 <td valign="top">
83 Flag to disable DTD support. DTD support is needed to
84 validate XSD files themselves, amongst others.
85 </td>
86 <td valign="top" align="center">No - default false</td>
87 </tr>
88 <tr>
89 <td valign="top">failonerror</td>
90 <td valign="top">fails on a error if set to true (defaults to true).</td>
91 <td align="center" valign="top">No</td>
92 </tr>
93 <tr>
94 <td valign="top">file</td>
95 <td valign="top">the file(s) you want to check. (optionally can use an embedded fileset)</td>
96 <td valign="top" align="center">No</td>
97 </tr>
98 <tr>
99 <td valign="top">fullchecking</td>
100 <td valign="top">
101 enable full schema checking. Slow but strict.
102 </td>
103 <td valign="top" align="center">No - default true</td>
104 </tr>
105
106 <tr>
107 <td valign="top">lenient</td>
108 <td valign="top">
109 if true, only check the XML document is well formed
110 </td>
111 <td valign="top" align="center">No</td>
112 </tr>
113 <tr>
114 <td valign="top">noNamespaceFile</td>
115 <td valign="top">
116 filename of a no-namespace XSD file to provide the
117 schema for no-namespace XML content.
118 </td>
119 <td valign="top" align="center">No</td>
120 </tr>
121 <tr>
122 <td valign="top">noNamespaceURL</td>
123 <td valign="top">
124 URL of a no-namespace XSD file to provide the
125 schema for no-namespace XML content.
126 </td>
127 <td valign="top" align="center">No</td>
128 </tr>
129 <tr>
130 <td valign="top">warn</td>
131 <td valign="top">log parser warn events.</td>
132 <td align="center" valign="top">No</td>
133 </tr>
134</table>
135
136<h3><a name="nested">Nested Elements</a></h3>
137
138
139<h4>schema</h4>
140<p>
141Identify the name and location of a schema that may be used in validating
142the document(s).
143</p>
144<table border="1" cellpadding="2" cellspacing="0">
145<tr>
146 <td width="12%" valign="top"><b>Attribute</b></td>
147 <td width="78%" valign="top"><b>Description</b></td>
148 <td width="10%" valign="top"><b>Required</b></td>
149</tr>
150 <tr>
151 <td valign="top">namespace</td>
152 <td valign="top">URI of the schema namespace</td>
153 <td align="center" valign="top">Yes</td>
154 </tr>
155 <tr>
156 <td valign="top">url</td>
157 <td valign="top">URL of the schema</td>
158 <td align="center" valign="top">One of url or file is required</td>
159 </tr>
160 <tr>
161 <td valign="top">file</td>
162 <td valign="top">file of the schema</td>
163 <td align="center" valign="top">One of url or file is required</td>
164 </tr>
165</table>
166
167<h4>dtd</h4>
168<p>
169<tt>&lt;dtd&gt;</tt> is used to specify different locations for DTD resolution.
170</p>
171<table border="1" cellpadding="2" cellspacing="0">
172<tr>
173 <td width="12%" valign="top"><b>Attribute</b></td>
174 <td width="78%" valign="top"><b>Description</b></td>
175 <td width="10%" valign="top"><b>Required</b></td>
176</tr>
177 <tr>
178 <td valign="top">publicId</td>
179 <td valign="top">Public ID of the DTD to resolve</td>
180 <td align="center" valign="top">Yes</td>
181 </tr>
182 <tr>
183 <td valign="top">location</td>
184 <td valign="top">Location of the DTD to use, which can be a file,
185 a resource, or a URL</td>
186 <td align="center" valign="top">Yes</td>
187 </tr>
188</table>
189<h4>xmlcatalog</h4>
190<p>The <a href="../CoreTypes/xmlcatalog.html"><tt>&lt;xmlcatalog&gt;</tt></a>
191element is used to perform entity resolution.</p>
192<h4>attribute</h4>
193<p>The <tt>&lt;attribute&gt;</tt> element is used to set parser features.<br>
194Features usable with the xerces parser are defined here :
195 <a href="http://xml.apache.org/xerces-j/features.html">Setting features</a><br>
196
197SAX features are defined here:
198 <a href="http://www.saxproject.org/apidoc/org/xml/sax/package-summary.html#package_description"><tt>http://xml.org/sax/features/</tt></a><br>
199 </p>
200<table border="1" cellpadding="2" cellspacing="0">
201<tr>
202 <td width="12%" valign="top"><b>Attribute</b></td>
203 <td width="78%" valign="top"><b>Description</b></td>
204 <td width="10%" valign="top"><b>Required</b></td>
205</tr>
206 <tr>
207 <td valign="top">name</td>
208 <td valign="top">The name of the feature</td>
209 <td align="center" valign="top">Yes</td>
210 </tr>
211 <tr>
212 <td valign="top">value</td>
213 <td valign="top">The boolean value of the feature</td>
214 <td align="center" valign="top">Yes</td>
215 </tr>
216</table>
217</p>
218
219<h4>property</h4>
220<p>The <tt>&lt;property&gt;</tt> element is used to set properties.
221These properties are defined here for the xerces XML parser implementation :
222 <a href="http://xml.apache.org/xerces-j/properties.html">XML Parser properties</a>
223Properties can be used to set the schema used to validate the XML file.
224</p>
225<table border="1" cellpadding="2" cellspacing="0">
226<tr>
227 <td width="12%" valign="top"><b>Attribute</b></td>
228 <td width="78%" valign="top"><b>Description</b></td>
229 <td width="10%" valign="top"><b>Required</b></td>
230</tr>
231 <tr>
232 <td valign="top">name</td>
233 <td valign="top">The name of the feature</td>
234 <td align="center" valign="top">Yes</td>
235 </tr>
236 <tr>
237 <td valign="top">value</td>
238 <td valign="top">The string value of the property</td>
239 <td align="center" valign="top">Yes</td>
240 </tr>
241</table>
242</p>
243
244
245<h3>Examples</h3>
246<pre>
247 &lt;schemavalidate
248 noNamespaceFile="document.xsd"
249 file="xml/endpiece.xml"&gt;
250 &lt;/schemavalidate&gt;
251</pre>
252Validate a document against an XML schema. The document does not declare
253any schema itself, which is why the <tt>noNamespaceFile</tt> is needed.
254<pre>
255 &lt;presetdef name="validate-soap"&gt;
256 &lt;schemavalidate &gt;
257 &lt;schema namespace="http://schemas.xmlsoap.org/ws/2003/03/addressing"
258 file="${soap.dir}/ws-addressing.xsd" /&gt;
259 &lt;schema namespace="http://www.w3.org/2003/05/soap-envelope"
260 file="${soap.dir}/soap12.xsd" /&gt;
261 &lt;schema namespace="http://schemas.xmlsoap.org/wsdl/"
262 file="${soap.dir}/wsdl.xsd" /&gt;
263 &lt;schema namespace="http://www.w3.org/2001/XMLSchema"
264 file="${soap.dir}/XMLSchema.xsd" /&gt;
265 &lt;/schemavalidate&gt;
266 &lt;/presetdef&gt;
267</pre>
268Declare a new preset task, <tt>&lt;validate-soap&gt;</tt>, that validates
269XSD and WSDL documents against the relevant specifications.
270To validate XSD documents, you also need XMLSchema.dtd and datatypes.dtd in
271the same directory as XMLSchema.xsd, or pointed to via the catalog. All
272these files can be fetched from <a href="http://www.w3.org/2001/XMLSchema">
273the W3C</a>.
274<pre>
275 &lt;validate-soap file="xml/test.xsd"/&gt;
276</pre>
277Use the preset task defined above to validate an XML Schema document.
278<br>
279
280
281</body>
282</html>
283
Note: See TracBrowser for help on using the repository browser.