Class 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 Detail

      • INTRINSIC_NS_URI

        private static final java.lang.String INTRINSIC_NS_URI
        See Also:
        Constant Field Values
      • validationSets

        @Parameter
        private ValidationSet[] validationSets
        Specifies a set of document types, which are being validated.
    • Constructor Detail

      • ValidateMojo

        public ValidateMojo()
    • Method Detail

      • getSchema

        private javax.xml.validation.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,
                              javax.xml.validation.Schema pSchema,
                              java.io.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 javax.xml.parsers.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,
                           java.io.File pFile,
                           org.xml.sax.ErrorHandler errorHandler)
                    throws java.io.IOException,
                           org.xml.sax.SAXException,
                           javax.xml.parsers.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:
        java.io.IOException - An I/O error occurred.
        org.xml.sax.SAXException - Parsing the file failed.
        javax.xml.parsers.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.