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.
-
Nested Class Summary
Nested classes/interfaces inherited from class AbstractXmlMojo
AbstractXmlMojo.CatalogHandling -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Stringprivate ValidationSet[]Specifies a set of document types, which are being validated.Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidappendMessage(StringBuffer messageBuffer, ValidationErrorHandler.ErrorRecord error) voidexecute()Called by Maven for executing the Mojo.private SchemagetSchema(Resolver pResolver, ValidationSet pValidationSet) Reads a validation sets schema.private SAXParserFactorynewSAXParserFactory(ValidationSet pValidationSet) Creates a new instance ofSAXParserFactory.private voidparse(Resolver pResolver, ValidationSet pValidationSet, File pFile, ErrorHandler errorHandler) Called for validating a single file.private voidvalidate(Resolver pResolver, ValidationSet pValidationSet, Schema pSchema, File pFile, ValidationErrorHandler errorHandler) Called for parsing or validating a single file.private voidvalidate(Resolver pResolver, ValidationSet pValidationSet, ValidationErrorHandler errorHandler) Called for validating a set of XML files against a common schema.Methods inherited from class AbstractXmlMojo
activateProxy, asAbsoluteFile, asFiles, checkCatalogHandling, getBasedir, getCatalogHandling, getExcludes, getFileNames, getFiles, getLocator, getProject, getResolver, getResource, isSkipping, passivateProxy, setCatalogsMethods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
Field Details
-
INTRINSIC_NS_URI
- See Also:
-
validationSets
Specifies a set of document types, which are being validated.
-
-
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
Creates a new instance ofSAXParserFactory.- 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.MojoFailureExceptionCalled 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
-