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:
Cloneable
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
Modifier and TypeClassDescriptionstatic class
representation 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
Modifier and TypeFieldDescriptionstatic final String
Duplicate declaration of schemastatic final String
schema features not supportedstatic final String
unable to create parserstatic final String
SAX1 not supportedstatic final String
too many default schemasstatic final String
adding 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
Fields inherited from class org.apache.tools.ant.ProjectComponent
description, location, project
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
add the schemaprotected void
build a string list of all schema locations, then set the relevant property.protected void
create a schema location to hold the anonymous schemaprotected XMLReader
Create a reader if the use of the class did not specify another one.boolean
Set schema attributes in a JAXP 1.2 engine.boolean
Turn on XSD support in Xerces.protected String
get the URL of the no namespace schemavoid
init()
Called by the project to let the task initialize properly.protected void
init the parser : load the parser class, and set features if necessary It is only after this that the reader is validprotected void
onSuccessfulValidation
(int fileProcessed) handler called on successful file validation.void
setDisableDTD
(boolean disableDTD) flag to disable DTD support.protected void
setFeatureIfSupported
(String feature, boolean value) set a feature if it is supported, log at verbose level if notvoid
setFullChecking
(boolean fullChecking) enable full schema checking.void
setNoNamespaceFile
(File defaultSchemaFile) identify a file containing the default schemavoid
setNoNamespaceURL
(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, setWarn
Methods 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, setTaskType
Methods inherited from class org.apache.tools.ant.ProjectComponent
clone, getDescription, getLocation, getProject, setDescription, setLocation, setProject
-
Field Details
-
ERROR_SAX_1
-
ERROR_NO_XSD_SUPPORT
-
ERROR_TOO_MANY_DEFAULT_SCHEMAS
-
ERROR_PARSER_CREATION_FAILURE
-
MESSAGE_ADDING_SCHEMA
-
ERROR_DUPLICATE_SCHEMA
-
-
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:
init
in 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:
-
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
- aboolean
value.
-
createAnonymousSchema
protected void createAnonymousSchema()create a schema location to hold the anonymous schema -
setNoNamespaceURL
identify the URL of the default schema- Parameters:
defaultSchemaURL
- the URL of the default schema.
-
setNoNamespaceFile
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
- aboolean
value.
-
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:
initValidator
in classXMLValidateTask
- Throws:
BuildException
- if something went wrong
-
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:
createDefaultReader
in classXMLValidateTask
- Returns:
- a default XML parser
-
addSchemaLocations
protected void addSchemaLocations()build a string list of all schema locations, then set the relevant property. -
getNoNamespaceSchemaURL
get the URL of the no namespace schema- Returns:
- the schema URL
-
setFeatureIfSupported
set a feature if it is supported, log at verbose level if not- Parameters:
feature
- the feature.value
- aboolean
value.
-
onSuccessfulValidation
protected void onSuccessfulValidation(int fileProcessed) handler called on successful file validation.- Overrides:
onSuccessfulValidation
in classXMLValidateTask
- Parameters:
fileProcessed
- number of files processed.
-