This schemavalidate task validates XML files described by an XML Schema. The task extends the XmlValidate task with XSD-specific features.
This task supports the use of nested
The task only supports SAX2 or later parsers: it is an error to specify a SAX1 parser.
Attribute | Description | Required |
classname | the parser to use. | No |
classpathref | where to find the parser class. Optionally can use an embedded <classpath> element. | No |
disableDTD | Flag to disable DTD support. DTD support is needed to validate XSD files themselves, amongst others. | No - default false |
failonerror | fails on a error if set to true (defaults to true). | No |
file | the file(s) you want to check. (optionally can use an embedded fileset) | No |
fullchecking | enable full schema checking. Slow but strict. | No - default true |
lenient | if true, only check the XML document is well formed | No |
noNamespaceFile | filename of a no-namespace XSD file to provide the schema for no-namespace XML content. | No |
noNamespaceURL | URL of a no-namespace XSD file to provide the schema for no-namespace XML content. | No |
warn | log parser warn events. | No |
Identify the name and location of a schema that may be used in validating the document(s).
Attribute | Description | Required |
namespace | URI of the schema namespace | Yes |
url | URL of the schema | One of url or file is required |
file | file of the schema | One of url or file is required |
<dtd> is used to specify different locations for DTD resolution.
Attribute | Description | Required |
publicId | Public ID of the DTD to resolve | Yes |
location | Location of the DTD to use, which can be a file, a resource, or a URL | Yes |
The <xmlcatalog> element is used to perform entity resolution.
The <attribute> element is used to set parser features.
Features usable with the xerces parser are defined here :
Setting features
SAX features are defined here:
http://xml.org/sax/features/
Attribute | Description | Required |
name | The name of the feature | Yes |
value | The boolean value of the feature | Yes |
The <property> element is used to set properties. These properties are defined here for the xerces XML parser implementation : XML Parser properties Properties can be used to set the schema used to validate the XML file.
Attribute | Description | Required |
name | The name of the feature | Yes |
value | The string value of the property | Yes |
<schemavalidate noNamespaceFile="document.xsd" file="xml/endpiece.xml"> </schemavalidate>Validate a document against an XML schema. The document does not declare any schema itself, which is why the noNamespaceFile is needed.
<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>Declare a new preset task, <validate-soap>, 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 the W3C.
<validate-soap file="xml/test.xsd"/>Use the preset task defined above to validate an XML Schema document.