org.apache.tools.ant.taskdefs.optional

Class SchemaValidate

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 referencies, Ant may need its proxy set up, using the setproxy task. Hands off most of the work to its parent, {@link XMLValidateTask}

Since: Ant1.7

Nested Class Summary
static classSchemaValidate.SchemaLocation
representation of a schema location.
Field Summary
static StringERROR_DUPLICATE_SCHEMA
Duplicate declaration of schema
static StringERROR_NO_XSD_SUPPORT
schema features not supported
static StringERROR_PARSER_CREATION_FAILURE
unable to create parser
static StringERROR_SAX_1
SAX1 not supported
static StringERROR_TOO_MANY_DEFAULT_SCHEMAS
too many default schemas
static StringMESSAGE_ADDING_SCHEMA
adding schema
Method Summary
voidaddConfiguredSchema(SchemaValidate.SchemaLocation location)
add the schema
protected voidaddSchemaLocations()
build a string list of all schema locations, then set the relevant property.
protected voidcreateAnonymousSchema()
create a schema location to hold the anonymous schema
protected 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 StringgetNoNamespaceSchemaURL()
get the URL of the no namespace schema
voidinit()
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 valid
protected voidonSuccessfulValidation(int fileProcessed)
handler called on successful file validation.
voidsetDisableDTD(boolean disableDTD)
flag to disable DTD support.
protected voidsetFeatureIfSupported(String feature, boolean value)
set a feature if it is supported, log at verbose level if not
voidsetFullChecking(boolean fullChecking)
enable full schema checking.
voidsetNoNamespaceFile(File defaultSchemaFile)
identify a file containing the default schema
voidsetNoNamespaceURL(String defaultSchemaURL)
identify the URL of the default schema

Field Detail

ERROR_DUPLICATE_SCHEMA

public static final String ERROR_DUPLICATE_SCHEMA
Duplicate declaration of schema

ERROR_NO_XSD_SUPPORT

public static final String ERROR_NO_XSD_SUPPORT
schema features not supported

ERROR_PARSER_CREATION_FAILURE

public static final String ERROR_PARSER_CREATION_FAILURE
unable to create parser

ERROR_SAX_1

public static final String ERROR_SAX_1
SAX1 not supported

ERROR_TOO_MANY_DEFAULT_SCHEMAS

public static final String ERROR_TOO_MANY_DEFAULT_SCHEMAS
too many default schemas

MESSAGE_ADDING_SCHEMA

public static final String MESSAGE_ADDING_SCHEMA
adding schema

Method Detail

addConfiguredSchema

public void addConfiguredSchema(SchemaValidate.SchemaLocation location)
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

addSchemaLocations

protected void addSchemaLocations()
build a string list of all schema locations, then set the relevant property.

createAnonymousSchema

protected void createAnonymousSchema()
create a schema location to hold the anonymous schema

createDefaultReader

protected XMLReader createDefaultReader()
Create a reader if the use of the class did not specify another one. The reason to not use {@link JAXPUtils#getXMLReader()} was to create our own factory with our own options.

Returns: a default XML parser

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

enableXercesSchemaValidation

public boolean enableXercesSchemaValidation()
Turn on XSD support in Xerces.

Returns: true on success, false on failure

getNoNamespaceSchemaURL

protected String getNoNamespaceSchemaURL()
get the URL of the no namespace schema

Returns: the schema URL

init

public void init()
Called by the project to let the task initialize properly. The default implementation is a no-op.

Throws: BuildException if something goes wrong with the build

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

Throws: BuildException if something went wrong

onSuccessfulValidation

protected void onSuccessfulValidation(int fileProcessed)
handler called on successful file validation.

Parameters: fileProcessed number of files processed.

setDisableDTD

public void setDisableDTD(boolean disableDTD)
flag to disable DTD support.

Parameters: disableDTD a boolean value.

setFeatureIfSupported

protected void setFeatureIfSupported(String feature, boolean value)
set a feature if it is supported, log at verbose level if not

Parameters: feature the feature. value a boolean value.

setFullChecking

public void setFullChecking(boolean fullChecking)
enable full schema checking. Slower but better.

Parameters: fullChecking a boolean value.

setNoNamespaceFile

public void setNoNamespaceFile(File defaultSchemaFile)
identify a file containing the default schema

Parameters: defaultSchemaFile the location of the default schema.

setNoNamespaceURL

public void setNoNamespaceURL(String defaultSchemaURL)
identify the URL of the default schema

Parameters: defaultSchemaURL the URL of the default schema.