Package org.codehaus.mojo.xml
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 AbstractXmlMojoThe ValidatorMojo's task is the validation of XML files against a given schema.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.codehaus.mojo.xml.AbstractXmlMojo
AbstractXmlMojo.CatalogHandling
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringINTRINSIC_NS_URIprivate ValidationSet[]validationSetsSpecifies a set of document types, which are being validated.
-
Constructor Summary
Constructors Constructor Description ValidateMojo()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidappendMessage(java.lang.StringBuffer messageBuffer, ValidationErrorHandler.ErrorRecord error)voidexecute()Called by Maven for executing the Mojo.private javax.xml.validation.SchemagetSchema(Resolver pResolver, ValidationSet pValidationSet)Reads a validation sets schema.private javax.xml.parsers.SAXParserFactorynewSAXParserFactory(ValidationSet pValidationSet)Creates a new instance ofSAXParserFactory.private voidparse(Resolver pResolver, ValidationSet pValidationSet, java.io.File pFile, org.xml.sax.ErrorHandler errorHandler)Called for validating a single file.private voidvalidate(Resolver pResolver, ValidationSet pValidationSet, javax.xml.validation.Schema pSchema, java.io.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 org.codehaus.mojo.xml.AbstractXmlMojo
activateProxy, asAbsoluteFile, asFiles, checkCatalogHandling, getBasedir, getCatalogHandling, getExcludes, getFileNames, getFiles, getLocator, getProject, getResolver, getResource, isSkipping, passivateProxy, setCatalogs
-
-
-
-
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.
-
-
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 ofSAXParserFactory.- 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.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
private void appendMessage(java.lang.StringBuffer messageBuffer, ValidationErrorHandler.ErrorRecord error)
-
-