|
|
@@ -15,8 +15,8 @@ The task extends the XmlValidate task with XSD-specific features.</p> |
|
|
|
<li>The parser is created validating and namespace aware |
|
|
|
</li> |
|
|
|
<li>Validation is turned on.</li> |
|
|
|
<li>and Schema validation is turned on.</li> |
|
|
|
<li>Any default schema supplied is used as the no-namespace schema |
|
|
|
<li>Schema validation is turned on.</li> |
|
|
|
<li>Any no-namespace schema URL or file supplied is used as the no-namespace schema |
|
|
|
<li>All nested schema declarations are turned into the list of namespace-url |
|
|
|
bindings for schema lookup. |
|
|
|
</ol> |
|
|
@@ -50,35 +50,34 @@ parser. |
|
|
|
<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> |
|
|
|
<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">defaultSchemaFile</td> |
|
|
|
<td valign="top"> |
|
|
|
filename of a no-namespace XSD file to provide the |
|
|
|
schema for no-namespace XML content. |
|
|
|
</td> |
|
|
|
<td valign="top" align="center">No</td> |
|
|
|
<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">noNamespaceURL</td> |
|
|
|
<td valign="top">disableDTD</td> |
|
|
|
<td valign="top"> |
|
|
|
URL of a no-namespace XSD file to provide the |
|
|
|
schema for no-namespace XML content. |
|
|
|
Flag to disable DTD support. DTD support is needed to |
|
|
|
validate XSD files themselves, amongst others. |
|
|
|
</td> |
|
|
|
<td valign="top" align="center">No</td> |
|
|
|
<td valign="top" align="center">No - default false</td> |
|
|
|
</tr> |
|
|
|
<tr> |
|
|
|
<td valign="top">noNamespaceFile</td> |
|
|
|
<td valign="top"> |
|
|
|
filename of a no-namespace XSD file to provide the |
|
|
|
schema for no-namespace XML content. |
|
|
|
</td> |
|
|
|
<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">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">fullchecking</td> |
|
|
|
<td valign="top"> |
|
|
@@ -86,6 +85,7 @@ parser. |
|
|
|
</td> |
|
|
|
<td valign="top" align="center">No - default true</td> |
|
|
|
</tr> |
|
|
|
|
|
|
|
<tr> |
|
|
|
<td valign="top">lenient</td> |
|
|
|
<td valign="top"> |
|
|
@@ -94,20 +94,20 @@ parser. |
|
|
|
<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> |
|
|
|
<td valign="top">noNamespaceFile</td> |
|
|
|
<td valign="top"> |
|
|
|
filename of a no-namespace XSD file to provide the |
|
|
|
schema for no-namespace XML content. |
|
|
|
</td> |
|
|
|
<td valign="top" align="center">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> |
|
|
|
<td valign="top">noNamespaceURL</td> |
|
|
|
<td valign="top"> |
|
|
|
URL of a no-namespace XSD file to provide the |
|
|
|
schema for no-namespace XML content. |
|
|
|
</td> |
|
|
|
<td valign="top" align="center">No</td> |
|
|
|
</tr> |
|
|
|
<tr> |
|
|
|
<td valign="top">warn</td> |
|
|
@@ -227,79 +227,37 @@ Properties can be used to set the schema used to validate the XML file. |
|
|
|
|
|
|
|
<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> |
|
|
|
<schemavalidate |
|
|
|
noNamespaceFile="document.xsd" |
|
|
|
file="xml/endpiece.xml"> |
|
|
|
</schemavalidate> |
|
|
|
</pre> |
|
|
|
Scan all XML files in the project, using the catalog defined inline. |
|
|
|
|
|
|
|
Validate a document against an XML schema. The document does not declare |
|
|
|
any schema itself, which is why the <tt>noNamespaceFile</tt> is needed. |
|
|
|
<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"/> |
|
|
|
<attribute name="http://xml.org/sax/features/namespaces" value="true"/> |
|
|
|
</xmlvalidate> |
|
|
|
<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> |
|
|
|
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> |
|
|
|
Declare a new preset task, <tt><validate-soap></tt>, that validates |
|
|
|
XSD and WSDL documents against the relevant specifications. |
|
|
|
To validate XSD documents, you also need XMLSchema.dtd and datatypes.dtd in |
|
|
|
the same directory as XMLSchema.xsd, or pointed to via the catalog. All |
|
|
|
these files can be fetched from <a href="http://www.w3.org/2001/XMLSchema"> |
|
|
|
the W3C</a>. |
|
|
|
<pre> |
|
|
|
<!-- Converts path to URL format --> |
|
|
|
<pathconvert dirsep="/" property="xsd.file"> |
|
|
|
<path> |
|
|
|
<pathelement location="xml/doc.xsd"/> |
|
|
|
</path> |
|
|
|
</pathconvert> |
|
|
|
|
|
|
|
<xmlvalidate file="xml/endpiece-noSchema.xml" lenient="false" |
|
|
|
failonerror="true" warn="true"> |
|
|
|
<attribute name="http://apache.org/xml/features/validation/schema" |
|
|
|
value="true"/> |
|
|
|
<attribute name="http://xml.org/sax/features/namespaces" value="true"/> |
|
|
|
<property |
|
|
|
name="http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation" |
|
|
|
value="${xsd.file}"/> |
|
|
|
</xmlvalidate> |
|
|
|
<validate-soap file="xml/test.xsd"/> |
|
|
|
</pre> |
|
|
|
<br> |
|
|
|
Validate the file xml/endpiece-noSchema.xml against the schema xml/doc.xsd. |
|
|
|
Use the preset task defined above to validate an XML Schema document. |
|
|
|
<br> |
|
|
|
<hr> |
|
|
|
<p align="center">Copyright © 2001-2002,2004-2005 The Apache Software Foundation. All rights |
|
|
|