diff --git a/docs/manual/OptionalTasks/schemavalidate.html b/docs/manual/OptionalTasks/schemavalidate.html index 217f0319e..725ff4e57 100644 --- a/docs/manual/OptionalTasks/schemavalidate.html +++ b/docs/manual/OptionalTasks/schemavalidate.html @@ -15,8 +15,8 @@ The task extends the XmlValidate task with XSD-specific features.
-<xmlvalidate file="toto.xml"/> --Validate toto.xml -
-<xmlvalidate failonerror="no" lenient="yes" warn="yes" - classname="org.apache.xerces.parsers.SAXParser"> - classpath="lib/xerces.jar"> - <fileset dir="src" includes="style/*.xsl"/> -</xmlvalidate> --Validate all .xsl files in src/style, but only warn if there is an error, rather than -halt the build. -
- -<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> -- -Validate a struts configuration, using a local copy of the DTD. -
-<xmlvalidate failonerror="no"> - <fileset dir="${project.dir}" includes="**/*.xml"/> - <xmlcatalog refid="mycatalog"/> -</xmlvalidate> -- -Scan all XML files in the project, using a predefined catalog to map URIs to local files. -
-<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>-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 noNamespaceFile is needed.
-<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>-Validate all .xml files in xml directory with the parser configured to perform schema validation. Note: The parser must support the -
http://apache.org/xml/features/validation/schemafeature. - -
- -<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"/>-
Copyright © 2001-2002,2004-2005 The Apache Software Foundation. All rights diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/SchemaValidate.java b/src/main/org/apache/tools/ant/taskdefs/optional/SchemaValidate.java index 70b5a24be..8e57a3c15 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/SchemaValidate.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/SchemaValidate.java @@ -56,6 +56,8 @@ public class SchemaValidate extends XMLValidateTask { /** full checking of a schema */ private boolean fullChecking=true; + private boolean disableDTD=false; + /** * default URL for nonamespace schemas */ @@ -178,6 +180,14 @@ public class SchemaValidate extends XMLValidateTask { this.anonymousSchema.setFile(defaultSchemaFile); } + /** + * flag to disable DTD support. + * @param disableDTD + */ + public void setDisableDTD(boolean disableDTD) { + this.disableDTD = disableDTD; + } + /** * init the parser : load the parser class, and set features if necessary It * is only after this that the reader is valid @@ -186,7 +196,6 @@ public class SchemaValidate extends XMLValidateTask { */ protected void initValidator() { super.initValidator(); - XMLReader xmlReader = getXmlReader(); //validate the parser type if(isSax1Parser()) { throw new BuildException(ERROR_SAX_1); @@ -204,8 +213,8 @@ public class SchemaValidate extends XMLValidateTask { //enable schema checking setFeature(XmlConstants.FEATURE_XSD_FULL_VALIDATION,fullChecking); - //turn off DTDs - setFeatureIfSupported(XmlConstants.FEATURE_DISALLOW_DTD,true); + //turn off DTDs if desired + setFeatureIfSupported(XmlConstants.FEATURE_DISALLOW_DTD,disableDTD); //schema declarations go in next addSchemaLocations(); }