public class LabelValidator extends Object
Modifier and Type | Field and Description |
---|---|
static String |
SCHEMA_CHECK |
static String |
SCHEMATRON_CHECK |
Constructor and Description |
---|
LabelValidator()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addValidator(DocumentValidator validator) |
void |
addValidator(ExternalValidator validator) |
Pattern |
getBundleLabelPattern() |
XMLCatalogResolver |
getCatalogResolver() |
Pattern |
getCollectionLabelPattern() |
Boolean |
getConfiguration(String key) |
long |
getFilesProcessed()
Returns the number of files processed by the validation function.
|
List<String> |
getSchematrons(NodeList nodeList,
URL url,
ProblemHandler handler) |
double |
getTotalTimeElapsed()
Returns the duration it took to run the validation function.
|
static void |
main(String[] args) |
Document |
parseAndValidate(ProblemHandler handler,
URL url)
Parses and validates a label against the schema and Schematron files, and returns the parsed
XML.
|
Boolean |
performsSchematronValidation() |
Boolean |
performsSchemaValidation() |
void |
setBundleLabelPattern(Pattern bundleLabelPattern) |
void |
setCachedEntityResolver(CachedEntityResolver resolver) |
void |
setCachedLSResourceResolver(CachedLSResourceResolver resolver) |
void |
setCatalogs(String[] catalogFiles)
Pass in a list of Catalog files to use during the validation step.
|
void |
setCollectionLabelPattern(Pattern collectionLabelPattern) |
void |
setConfiguration(String key,
Boolean value) |
void |
setLabelExtension(String extension) |
void |
setLabelSchematrons(Map<String,Transformer> schematronMap)
Pass in a hash map of schematron URLs to its transformed schematron object.
|
void |
setSchema(List<URL> schemaFiles)
Pass in a list of schemas to validate against.
|
void |
setSchemaCheck(Boolean value) |
void |
setSchemaCheck(Boolean value,
Boolean useLabelSchema) |
void |
setSchematronCheck(Boolean value) |
void |
setSchematronCheck(Boolean value,
Boolean useLabelSchematron) |
void |
setSchematronFiles(List<URL> schematronFiles)
Pass in a list of schematron files to validate against.
|
void |
setSchematrons(List<Transformer> schematrons)
Pass in a list of transformed schematrons to validate against.
|
void |
setSkipProductValidation(Boolean flag) |
void |
validate(File labelFile) |
void |
validate(ProblemHandler handler,
File labelFile) |
void |
validate(ProblemHandler handler,
URL url)
Validates the label against schema and schematron constraints.
|
void |
validate(ProblemHandler handler,
URL url,
String labelExtension) |
public static final String SCHEMA_CHECK
public static final String SCHEMATRON_CHECK
public LabelValidator() throws ParserConfigurationException, TransformerConfigurationException
ParserConfigurationException
- If there was an error setting up the configuration of the
parser that is reposnible for doing the label validation.TransformerConfigurationException
- If there was an error setting up the Transformer
responsible for doing the transformations of the schematrons.public long getFilesProcessed()
public double getTotalTimeElapsed()
public void setSchema(List<URL> schemaFiles)
schemaFiles
- A list of schema URLs.public void setSchematrons(List<Transformer> schematrons)
schematrons
- A list of transformed schematrons.public void setLabelSchematrons(Map<String,Transformer> schematronMap)
schematronMap
- public void setSchematronFiles(List<URL> schematronFiles)
schematronFiles
- A list of schematron URLs.public void setCatalogs(String[] catalogFiles)
catalogFiles
- public XMLCatalogResolver getCatalogResolver()
public void validate(ProblemHandler handler, File labelFile) throws SAXException, IOException, ParserConfigurationException, TransformerException, MissingLabelSchemaException
public void validate(ProblemHandler handler, URL url) throws SAXException, IOException, ParserConfigurationException, TransformerException, MissingLabelSchemaException
handler
- a handler to receive errors during the validationurl
- label to validateSAXException
- if there are parsing exceptionsIOException
- if there are I/O errors during the parseParserConfigurationException
- if the parser configuration is invalidTransformerException
- if there is an error during Schematron transformationMissingLabelSchemaException
- if the label schema cannot be foundpublic void validate(ProblemHandler handler, URL url, String labelExtension) throws SAXException, IOException, ParserConfigurationException, TransformerException, MissingLabelSchemaException
public Document parseAndValidate(ProblemHandler handler, URL url) throws SAXException, IOException, ParserConfigurationException, TransformerException, MissingLabelSchemaException
handler
- an problem handler to receive errors during the validationurl
- the URL of the label to validateSAXException
- if there are parsing exceptionsIOException
- if there are I/O errors during the parseParserConfigurationException
- if the parser configuration is invalidTransformerException
- if there is an error during Schematron transformationMissingLabelSchemaException
- if the label schema cannot be foundpublic void validate(File labelFile) throws SAXException, IOException, ParserConfigurationException, TransformerException, MissingLabelSchemaException
public List<String> getSchematrons(NodeList nodeList, URL url, ProblemHandler handler)
public Boolean performsSchemaValidation()
public void setSchemaCheck(Boolean value)
public Boolean performsSchematronValidation()
public void setSchematronCheck(Boolean value)
public void setSkipProductValidation(Boolean flag)
public void addValidator(ExternalValidator validator)
public void addValidator(DocumentValidator validator)
public void setCachedEntityResolver(CachedEntityResolver resolver)
public void setCachedLSResourceResolver(CachedLSResourceResolver resolver)
public void setLabelExtension(String extension)
public Pattern getBundleLabelPattern()
public void setBundleLabelPattern(Pattern bundleLabelPattern)
public Pattern getCollectionLabelPattern()
public void setCollectionLabelPattern(Pattern collectionLabelPattern)
Copyright © 2023 Jet Propulsion Laboratory, California Institute of Technology. All rights reserved.