Class ValidateMojo

java.lang.Object
org.apache.maven.plugin.AbstractMojo
org.codehaus.mojo.xml.AbstractXmlMojo
org.codehaus.mojo.xml.ValidateMojo
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

@Mojo(name="validate", defaultPhase=TEST, threadSafe=true) public class ValidateMojo extends AbstractXmlMojo
The ValidatorMojo's task is the validation of XML files against a given schema.
  • Field Details

  • Constructor Details

    • ValidateMojo

      public ValidateMojo()
  • Method Details

    • getSchema

      private Schema getSchema(Resolver pResolver, ValidationSet pValidationSet) throws org.apache.maven.plugin.MojoExecutionException
      Reads a validation sets schema.
      Parameters:
      pResolver - The resolver to use for loading external entities.
      pValidationSet - The validation set to configure.
      Returns:
      The validation sets schema, if any, or null.
      Throws:
      org.apache.maven.plugin.MojoExecutionException - Loading the schema failed.
    • validate

      private void validate(Resolver pResolver, ValidationSet pValidationSet, Schema pSchema, File pFile, ValidationErrorHandler errorHandler) throws org.apache.maven.plugin.MojoExecutionException
      Called for parsing or validating a single file.
      Parameters:
      pResolver - The resolver to use for loading external entities.
      pValidationSet - The parsers or validators configuration.
      pSchema - The schema to use.
      pFile - The file to parse or validate.
      Throws:
      org.apache.maven.plugin.MojoExecutionException - Parsing or validating the file failed.
    • newSAXParserFactory

      private SAXParserFactory newSAXParserFactory(ValidationSet pValidationSet)
      Creates a new instance of SAXParserFactory.
      Parameters:
      pValidationSet - The parser factories configuration.
      Returns:
      A new SAX parser factory.
    • parse

      private void parse(Resolver pResolver, ValidationSet pValidationSet, File pFile, ErrorHandler errorHandler) throws IOException, SAXException, ParserConfigurationException
      Called for validating a single file.
      Parameters:
      pResolver - The resolver to use for loading external entities.
      pValidationSet - The validators configuration.
      pFile - The file to validate.
      Throws:
      IOException - An I/O error occurred.
      SAXException - Parsing the file failed.
      ParserConfigurationException - Creating an XML parser failed.
    • validate

      private void validate(Resolver pResolver, ValidationSet pValidationSet, ValidationErrorHandler errorHandler) throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException
      Called for validating a set of XML files against a common schema.
      Parameters:
      pResolver - The resolver to use for loading external entities.
      pValidationSet - The set of XML files to validate.
      Throws:
      org.apache.maven.plugin.MojoExecutionException - Validating the set of files failed.
      org.apache.maven.plugin.MojoFailureException - A configuration error was detected.
    • execute

      public void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException
      Called by Maven for executing the Mojo.
      Throws:
      org.apache.maven.plugin.MojoExecutionException - Running the Mojo failed.
      org.apache.maven.plugin.MojoFailureException - A configuration error was detected.
    • appendMessage

      private void appendMessage(StringBuffer messageBuffer, ValidationErrorHandler.ErrorRecord error)