2018-12-21 11:20:43 +01:00
|
|
|
<!DOCTYPE html>
|
2006-09-11 04:19:00 +00:00
|
|
|
<!--
|
|
|
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
contributor license agreements. See the NOTICE file distributed with
|
|
|
|
this work for additional information regarding copyright ownership.
|
|
|
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
|
|
|
(the "License"); you may not use this file except in compliance with
|
|
|
|
the License. You may obtain a copy of the License at
|
|
|
|
|
2019-05-25 13:41:47 +02:00
|
|
|
https://www.apache.org/licenses/LICENSE-2.0
|
2006-09-11 04:19:00 +00:00
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
-->
|
2018-12-21 11:20:43 +01:00
|
|
|
<html lang="en">
|
2005-02-22 15:58:36 +00:00
|
|
|
|
|
|
|
<head>
|
2005-04-29 18:58:16 +00:00
|
|
|
<link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
|
2005-02-22 15:58:36 +00:00
|
|
|
<title>SchemaValidate Task</title>
|
|
|
|
</head>
|
|
|
|
|
|
|
|
<body>
|
|
|
|
|
2018-01-22 23:52:21 +01:00
|
|
|
<h2 id="schemavalidate">SchemaValidate</h2>
|
2005-02-22 15:58:36 +00:00
|
|
|
<h3>Description</h3>
|
|
|
|
|
2018-02-28 07:58:59 +01:00
|
|
|
<p>This <code>schemavalidate</code> task validates XML files described by an XML Schema. The task
|
|
|
|
extends the <code>XmlValidate</code> task with XSD-specific features.</p>
|
2005-02-22 15:58:36 +00:00
|
|
|
<ol>
|
2018-02-28 07:58:59 +01:00
|
|
|
<li>The parser is created validating and namespace aware.</li>
|
|
|
|
<li>Validation is turned on.</li>
|
|
|
|
<li>Schema validation is turned on.</li>
|
|
|
|
<li>Any no-namespace schema URL or file supplied is used as the no-namespace schema.</li>
|
|
|
|
<li>All nested schema declarations are turned into the list of namespace-url bindings for schema
|
|
|
|
lookup.</li>
|
2005-02-22 15:58:36 +00:00
|
|
|
</ol>
|
|
|
|
|
2018-02-28 07:58:59 +01:00
|
|
|
<p>Note that nested catalogs are still used for lookup of the URLs given as the sources of schema
|
|
|
|
documents, so you can still delegate lookup to a catalog, you just need to list all schema URIs and
|
|
|
|
their URL equivalents.</p>
|
2005-02-22 15:58:36 +00:00
|
|
|
|
2018-01-22 23:52:21 +01:00
|
|
|
<p>This task supports the use of nested</p>
|
|
|
|
<ul>
|
2018-02-28 07:58:59 +01:00
|
|
|
<li><a href="../Types/xmlcatalog.html"><code><xmlcatalog></code></a> elements</li>
|
|
|
|
<li><code><schema></code> elements, that bind a namespace URI to a URL or a local
|
|
|
|
filename.</li>
|
|
|
|
<li><code><dtd></code> elements which are used to resolve DTDs and entities.</li>
|
|
|
|
<li><code><attribute></code> elements which are used to set features on the parser. These
|
|
|
|
can be any number
|
2018-03-08 07:43:53 +01:00
|
|
|
of <a href="http://www.saxproject.org/apidoc/org/xml/sax/package-summary.html#package_description"
|
|
|
|
target="_top"><code>http://xml.org/sax/features/</code></a> or other features that your parser
|
|
|
|
may support.</li>
|
2018-02-28 07:58:59 +01:00
|
|
|
<li><code><property></code> elements, containing string properties</li>
|
2018-01-22 23:52:21 +01:00
|
|
|
</ul>
|
2005-02-22 15:58:36 +00:00
|
|
|
|
2018-03-08 07:43:53 +01:00
|
|
|
<p>The task only supports SAX2 or later parsers: it is an error to specify a SAX1 parser.</p>
|
2005-02-22 15:58:36 +00:00
|
|
|
|
|
|
|
<h3>Parameters</h3>
|
2018-02-28 07:58:59 +01:00
|
|
|
<table class="attr">
|
2005-02-22 15:58:36 +00:00
|
|
|
<tr>
|
2018-05-15 10:29:27 +02:00
|
|
|
<th scope="col">Attribute</th>
|
|
|
|
<th scope="col">Description</th>
|
|
|
|
<th scope="col">Required</th>
|
2005-02-22 15:58:36 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>classname</td>
|
|
|
|
<td>the parser to use.</td>
|
|
|
|
<td>No</td>
|
2005-02-22 15:58:36 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>classpathref</td>
|
|
|
|
<td>where to find the parser class. Optionally can use an
|
2018-03-02 08:23:45 +01:00
|
|
|
embedded <code><classpath></code> element.</td>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>No</td>
|
2005-02-22 15:58:36 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>disableDTD</td>
|
|
|
|
<td>Flag to disable DTD support. DTD support is needed to validate XSD files themselves, amongst
|
|
|
|
others.</td>
|
|
|
|
<td>No; default <q>false</q></td>
|
2005-02-22 15:58:36 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>failonerror</td>
|
2018-03-02 08:23:45 +01:00
|
|
|
<td>fails on a error if set to <q>true</q>.</td>
|
|
|
|
<td>No; defaults to <q>true</q></td>
|
2005-02-23 12:51:07 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>file</td>
|
|
|
|
<td>the file(s) you want to check (optionally use an embedded fileset).</td>
|
|
|
|
<td>No</td>
|
2005-02-22 15:58:36 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>fullchecking</td>
|
|
|
|
<td>enable full schema checking. Slow but strict.</td>
|
|
|
|
<td>No; default <q>true</q></td>
|
2005-02-22 15:58:36 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>lenient</td>
|
|
|
|
<td>if <q>true</q>, only check the XML document is well formed</td>
|
|
|
|
<td>No</td>
|
2005-02-22 15:58:36 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>noNamespaceFile</td>
|
|
|
|
<td>filename of a no-namespace XSD file to provide the schema for no-namespace XML content</td>
|
|
|
|
<td>No</td>
|
2005-02-22 15:58:36 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>noNamespaceURL</td>
|
|
|
|
<td>URL of a no-namespace XSD file to provide the schema for no-namespace XML content</td>
|
|
|
|
<td>No</td>
|
2005-02-22 15:58:36 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>warn</td>
|
|
|
|
<td>log parser warn events</td>
|
|
|
|
<td>No</td>
|
2005-02-22 15:58:36 +00:00
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
|
2018-03-05 17:35:30 +01:00
|
|
|
<h3 id="nested">Parameters specified as nested elements</h3>
|
2005-02-22 15:58:36 +00:00
|
|
|
|
|
|
|
<h4>schema</h4>
|
2018-02-28 07:58:59 +01:00
|
|
|
<p>Identify the name and location of a schema that may be used in validating the document(s).</p>
|
|
|
|
<table class="attr">
|
2005-02-22 15:58:36 +00:00
|
|
|
<tr>
|
2018-05-15 10:29:27 +02:00
|
|
|
<th scope="col">Attribute</th>
|
|
|
|
<th scope="col">Description</th>
|
|
|
|
<th scope="col">Required</th>
|
2005-02-22 15:58:36 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>namespace</td>
|
|
|
|
<td>URI of the schema namespace</td>
|
|
|
|
<td>Yes</td>
|
2005-02-22 15:58:36 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>url</td>
|
|
|
|
<td>URL of the schema</td>
|
|
|
|
<td rowspan="2">Exactly one of the two</td>
|
2005-02-22 15:58:36 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>file</td>
|
|
|
|
<td class="left">file of the schema</td>
|
2005-02-22 15:58:36 +00:00
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
|
|
|
|
<h4>dtd</h4>
|
2018-02-28 07:58:59 +01:00
|
|
|
<p><code><dtd></code> is used to specify different locations for DTD resolution.</p>
|
|
|
|
<table class="attr">
|
2005-02-22 15:58:36 +00:00
|
|
|
<tr>
|
2018-05-15 10:29:27 +02:00
|
|
|
<th scope="col">Attribute</th>
|
|
|
|
<th scope="col">Description</th>
|
|
|
|
<th scope="col">Required</th>
|
2005-02-22 15:58:36 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>publicId</td>
|
|
|
|
<td>Public ID of the DTD to resolve</td>
|
|
|
|
<td>Yes</td>
|
2005-02-22 15:58:36 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>location</td>
|
|
|
|
<td>Location of the DTD to use, which can be a file,
|
2005-02-22 15:58:36 +00:00
|
|
|
a resource, or a URL</td>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>Yes</td>
|
2005-02-22 15:58:36 +00:00
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
<h4>xmlcatalog</h4>
|
2018-02-28 07:58:59 +01:00
|
|
|
<p>The <a href="../Types/xmlcatalog.html"><code><xmlcatalog></code></a> element is used to
|
|
|
|
perform entity resolution.</p>
|
2005-02-22 15:58:36 +00:00
|
|
|
<h4>attribute</h4>
|
2018-03-02 08:23:45 +01:00
|
|
|
<p>The <code><attribute></code> element is used to set parser features.<br/>Features usable
|
2018-03-10 20:17:33 +01:00
|
|
|
with the Xerces parser are defined here: <a href="https://xml.apache.org/xerces-j/features.html"
|
2018-03-08 07:43:53 +01:00
|
|
|
target="_top">Setting features</a><br/>SAX features are defined
|
|
|
|
here: <a href="http://www.saxproject.org/apidoc/org/xml/sax/package-summary.html#package_description"
|
|
|
|
target="_top"><code>http://xml.org/sax/features/</code></a></p>
|
2018-02-28 07:58:59 +01:00
|
|
|
<table class="attr">
|
|
|
|
<tr>
|
2018-05-15 10:29:27 +02:00
|
|
|
<th scope="col">Attribute</th>
|
|
|
|
<th scope="col">Description</th>
|
|
|
|
<th scope="col">Required</th>
|
2005-02-22 15:58:36 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>name</td>
|
|
|
|
<td>The name of the feature</td>
|
|
|
|
<td>Yes</td>
|
2005-02-22 15:58:36 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>value</td>
|
|
|
|
<td>The boolean value of the feature</td>
|
|
|
|
<td>Yes</td>
|
2005-02-22 15:58:36 +00:00
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
|
|
|
|
<h4>property</h4>
|
2018-02-28 07:58:59 +01:00
|
|
|
<p>The <code><property></code> element is used to set properties. These properties are
|
|
|
|
defined here for the Xerces XML parser
|
2018-03-08 07:43:53 +01:00
|
|
|
implementation: <a href="https://xml.apache.org/xerces-j/properties.html" target="_top">XML Parser
|
|
|
|
properties</a>. Properties can be used to set the schema used to validate the XML file.
|
2005-02-22 15:58:36 +00:00
|
|
|
</p>
|
2018-02-28 07:58:59 +01:00
|
|
|
<table class="attr">
|
2005-02-22 15:58:36 +00:00
|
|
|
<tr>
|
2018-05-15 10:29:27 +02:00
|
|
|
<th scope="col">Attribute</th>
|
|
|
|
<th scope="col">Description</th>
|
|
|
|
<th scope="col">Required</th>
|
2005-02-22 15:58:36 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>name</td>
|
|
|
|
<td>The name of the feature</td>
|
|
|
|
<td>Yes</td>
|
2005-02-22 15:58:36 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>value</td>
|
|
|
|
<td>The string value of the property</td>
|
|
|
|
<td>Yes</td>
|
2005-02-22 15:58:36 +00:00
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
|
|
|
|
<h3>Examples</h3>
|
2018-05-15 09:51:58 +02:00
|
|
|
<p>Validate a document against an XML schema. The document does not declare any schema itself, which
|
|
|
|
is why the <var>noNamespaceFile</var> is needed.</p>
|
2005-02-22 15:58:36 +00:00
|
|
|
<pre>
|
2018-02-28 07:58:59 +01:00
|
|
|
<schemavalidate noNamespaceFile="document.xsd"
|
|
|
|
file="xml/endpiece.xml"/></pre>
|
2018-05-15 09:51:58 +02:00
|
|
|
|
|
|
|
<p>Declare a new preset task, <code><validate-soap></code>, that validates XSD and WSDL
|
|
|
|
documents against the relevant specifications. To validate XSD documents, you also
|
|
|
|
need <samp>XMLSchema.dtd</samp> and <samp>datatypes.dtd</samp> in the same directory
|
|
|
|
as <samp>XMLSchema.xsd</samp>, or pointed to via the catalog. All these files can be fetched
|
|
|
|
from <a href="https://www.w3.org/2001/XMLSchema" target="_top">W3C</a>.</p>
|
2005-02-22 15:58:36 +00:00
|
|
|
<pre>
|
2018-02-28 07:58:59 +01:00
|
|
|
<presetdef name="validate-soap">
|
|
|
|
<schemavalidate>
|
|
|
|
<schema namespace="http://schemas.xmlsoap.org/ws/2003/03/addressing"
|
|
|
|
file="${soap.dir}/ws-addressing.xsd"/>
|
|
|
|
<schema namespace="http://www.w3.org/2003/05/soap-envelope"
|
|
|
|
file="${soap.dir}/soap12.xsd"/>
|
|
|
|
<schema namespace="http://schemas.xmlsoap.org/wsdl/"
|
|
|
|
file="${soap.dir}/wsdl.xsd"/>
|
|
|
|
<schema namespace="http://www.w3.org/2001/XMLSchema"
|
|
|
|
file="${soap.dir}/XMLSchema.xsd"/>
|
|
|
|
</schemavalidate>
|
|
|
|
</presetdef></pre>
|
2018-05-15 09:51:58 +02:00
|
|
|
|
2018-02-28 07:58:59 +01:00
|
|
|
<p>Use the preset task defined above to validate an XML Schema document.</p>
|
2018-05-15 09:51:58 +02:00
|
|
|
<pre><validate-soap file="xml/test.xsd"/></pre>
|
2006-09-11 04:33:25 +00:00
|
|
|
|
2005-02-22 15:58:36 +00:00
|
|
|
</body>
|
|
|
|
</html>
|