Class SchemaValidate

All Implemented Interfaces:
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
  • Field Details

  • Constructor Details

    • SchemaValidate

      public SchemaValidate()
  • Method Details

    • init

      public void init() throws BuildException
      Called by the project to let the task initialize properly. The default implementation is a no-op.
      Overrides:
      init in class XMLValidateTask
      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

      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
    • setFullChecking

      public void setFullChecking(boolean fullChecking)
      enable full schema checking. Slower but better.
      Parameters:
      fullChecking - a boolean value.
    • createAnonymousSchema

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

      public void setNoNamespaceURL(String defaultSchemaURL)
      identify the URL of the default schema
      Parameters:
      defaultSchemaURL - the URL of the default schema.
    • setNoNamespaceFile

      public void setNoNamespaceFile(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 - a boolean 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 class XMLValidateTask
      Throws:
      BuildException - if something went wrong
    • createDefaultReader

      protected XMLReader createDefaultReader()
      Create a reader if the use of the class did not specify another one. The reason to not use JAXPUtils.getXMLReader() was to create our own factory with our own options.
      Overrides:
      createDefaultReader in class XMLValidateTask
      Returns:
      a default XML parser
    • addSchemaLocations

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

      protected String getNoNamespaceSchemaURL()
      get the URL of the no namespace schema
      Returns:
      the schema URL
    • 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.
    • onSuccessfulValidation

      protected void onSuccessfulValidation(int fileProcessed)
      handler called on successful file validation.
      Overrides:
      onSuccessfulValidation in class XMLValidateTask
      Parameters:
      fileProcessed - number of files processed.