Class SchemaValidate
java.lang.Object
org.apache.tools.ant.ProjectComponent
org.apache.tools.ant.Task
org.apache.tools.ant.taskdefs.optional.XMLValidateTask
org.apache.tools.ant.taskdefs.optional.SchemaValidate
- All Implemented Interfaces:
java.lang.Cloneable
public class SchemaValidate extends XMLValidateTask
Validate XML Schema documents.
This task validates XML schema documents. It requires an XML parser
that handles the relevant SAX, Xerces or JAXP options.
To resolve remote references, Ant may need its proxy set up, using the
setproxy task.
Hands off most of the work to its parent,
XMLValidateTask- Since:
- Ant1.7
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSchemaValidate.SchemaLocationrepresentation of a schema location.Nested classes/interfaces inherited from class org.apache.tools.ant.taskdefs.optional.XMLValidateTask
XMLValidateTask.Attribute, XMLValidateTask.Property, XMLValidateTask.ValidatorErrorHandler -
Field Summary
Fields Modifier and Type Field Description static java.lang.StringERROR_DUPLICATE_SCHEMADuplicate declaration of schemastatic java.lang.StringERROR_NO_XSD_SUPPORTschema features not supportedstatic java.lang.StringERROR_PARSER_CREATION_FAILUREunable to create parserstatic java.lang.StringERROR_SAX_1SAX1 not supportedstatic java.lang.StringERROR_TOO_MANY_DEFAULT_SCHEMAStoo many default schemasstatic java.lang.StringMESSAGE_ADDING_SCHEMAadding schemaFields inherited from class org.apache.tools.ant.taskdefs.optional.XMLValidateTask
classpath, errorHandler, failOnError, file, filesets, INIT_FAILED_MSG, lenient, MESSAGE_FILES_VALIDATED, readerClassName, warn, xmlReader -
Constructor Summary
Constructors Constructor Description SchemaValidate() -
Method Summary
Modifier and Type Method Description voidaddConfiguredSchema(SchemaValidate.SchemaLocation location)add the schemaprotected voidaddSchemaLocations()build a string list of all schema locations, then set the relevant property.protected voidcreateAnonymousSchema()create a schema location to hold the anonymous schemaprotected org.xml.sax.XMLReadercreateDefaultReader()Create a reader if the use of the class did not specify another one.booleanenableJAXP12SchemaValidation()Set schema attributes in a JAXP 1.2 engine.booleanenableXercesSchemaValidation()Turn on XSD support in Xerces.protected java.lang.StringgetNoNamespaceSchemaURL()get the URL of the no namespace schemavoidinit()Called by the project to let the task initialize properly.protected voidinitValidator()init the parser : load the parser class, and set features if necessary It is only after this that the reader is validprotected voidonSuccessfulValidation(int fileProcessed)handler called on successful file validation.voidsetDisableDTD(boolean disableDTD)flag to disable DTD support.protected voidsetFeatureIfSupported(java.lang.String feature, boolean value)set a feature if it is supported, log at verbose level if notvoidsetFullChecking(boolean fullChecking)enable full schema checking.voidsetNoNamespaceFile(java.io.File defaultSchemaFile)identify a file containing the default schemavoidsetNoNamespaceURL(java.lang.String defaultSchemaURL)identify the URL of the default schemaMethods inherited from class org.apache.tools.ant.taskdefs.optional.XMLValidateTask
addConfiguredXMLCatalog, addFileset, cleanup, createAttribute, createClasspath, createDTD, createProperty, createXmlReader, doValidate, execute, getEntityResolver, getXmlReader, isSax1Parser, setClassName, setClasspath, setClasspathRef, setFailOnError, setFeature, setFile, setLenient, setProperty, setWarnMethods inherited from class org.apache.tools.ant.Task
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskTypeMethods inherited from class org.apache.tools.ant.ProjectComponent
clone, getDescription, getLocation, getProject, setDescription, setLocation, setProject
-
Field Details
-
ERROR_SAX_1
public static final java.lang.String ERROR_SAX_1SAX1 not supported- See Also:
- Constant Field Values
-
ERROR_NO_XSD_SUPPORT
public static final java.lang.String ERROR_NO_XSD_SUPPORTschema features not supported- See Also:
- Constant Field Values
-
ERROR_TOO_MANY_DEFAULT_SCHEMAS
public static final java.lang.String ERROR_TOO_MANY_DEFAULT_SCHEMAStoo many default schemas- See Also:
- Constant Field Values
-
ERROR_PARSER_CREATION_FAILURE
public static final java.lang.String ERROR_PARSER_CREATION_FAILUREunable to create parser- See Also:
- Constant Field Values
-
MESSAGE_ADDING_SCHEMA
public static final java.lang.String MESSAGE_ADDING_SCHEMAadding schema- See Also:
- Constant Field Values
-
ERROR_DUPLICATE_SCHEMA
public static final java.lang.String ERROR_DUPLICATE_SCHEMADuplicate declaration of schema- See Also:
- Constant Field Values
-
-
Constructor Details
-
SchemaValidate
public SchemaValidate()
-
-
Method Details
-
init
Called by the project to let the task initialize properly. The default implementation is a no-op.- Overrides:
initin classXMLValidateTask- Throws:
BuildException- if something goes wrong with the build
-
enableXercesSchemaValidation
public boolean enableXercesSchemaValidation()Turn on XSD support in Xerces.- Returns:
- true on success, false on failure
-
enableJAXP12SchemaValidation
public boolean enableJAXP12SchemaValidation()Set schema attributes in a JAXP 1.2 engine.- Returns:
- true on success, false on failure
- See Also:
- JAXP 1.2 Approved CHANGES
-
addConfiguredSchema
add the schema- Parameters:
location- the schema location.- Throws:
BuildException- if there is no namespace, or if there already is a declaration of this schema with a different value
-
setFullChecking
public void setFullChecking(boolean fullChecking)enable full schema checking. Slower but better.- Parameters:
fullChecking- abooleanvalue.
-
createAnonymousSchema
protected void createAnonymousSchema()create a schema location to hold the anonymous schema -
setNoNamespaceURL
public void setNoNamespaceURL(java.lang.String defaultSchemaURL)identify the URL of the default schema- Parameters:
defaultSchemaURL- the URL of the default schema.
-
setNoNamespaceFile
public void setNoNamespaceFile(java.io.File defaultSchemaFile)identify a file containing the default schema- Parameters:
defaultSchemaFile- the location of the default schema.
-
setDisableDTD
public void setDisableDTD(boolean disableDTD)flag to disable DTD support.- Parameters:
disableDTD- abooleanvalue.
-
initValidator
protected void initValidator()init the parser : load the parser class, and set features if necessary It is only after this that the reader is valid- Overrides:
initValidatorin classXMLValidateTask- Throws:
BuildException- if something went wrong
-
createDefaultReader
protected org.xml.sax.XMLReader createDefaultReader()Create a reader if the use of the class did not specify another one. The reason to not useJAXPUtils.getXMLReader()was to create our own factory with our own options.- Overrides:
createDefaultReaderin classXMLValidateTask- Returns:
- a default XML parser
-
addSchemaLocations
protected void addSchemaLocations()build a string list of all schema locations, then set the relevant property. -
getNoNamespaceSchemaURL
protected java.lang.String getNoNamespaceSchemaURL()get the URL of the no namespace schema- Returns:
- the schema URL
-
setFeatureIfSupported
protected void setFeatureIfSupported(java.lang.String feature, boolean value)set a feature if it is supported, log at verbose level if not- Parameters:
feature- the feature.value- abooleanvalue.
-
onSuccessfulValidation
protected void onSuccessfulValidation(int fileProcessed)handler called on successful file validation.- Overrides:
onSuccessfulValidationin classXMLValidateTask- Parameters:
fileProcessed- number of files processed.
-