public class LabelValidator
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
SCHEMA_CHECK |
static java.lang.String |
SCHEMATRON_CHECK |
Constructor and Description |
---|
LabelValidator()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addValidator(DocumentValidator validator) |
void |
addValidator(ExternalValidator validator) |
XMLCatalogResolver |
getCatalogResolver() |
java.lang.Boolean |
getConfiguration(java.lang.String key) |
java.lang.String |
getModelVersion() |
java.util.List<java.lang.String> |
getSchematrons(org.w3c.dom.NodeList nodeList,
java.net.URL url,
ProblemHandler handler) |
static void |
main(java.lang.String[] args) |
org.w3c.dom.Document |
parseAndValidate(ProblemHandler handler,
java.net.URL url)
Parses and validates a label against the schema and Schematron files,
and returns the parsed XML.
|
java.lang.Boolean |
performsSchematronValidation() |
java.lang.Boolean |
performsSchemaValidation() |
void |
setCachedEntityResolver(CachedEntityResolver resolver) |
void |
setCachedLSResourceResolver(CachedLSResourceResolver resolver) |
void |
setCatalogs(java.lang.String[] catalogFiles)
Pass in a list of Catalog files to use during the validation
step.
|
void |
setConfiguration(java.lang.String key,
java.lang.Boolean value) |
void |
setLabelSchematrons(java.util.Map<java.lang.String,javax.xml.transform.Transformer> schematronMap)
Pass in a hash map of schematron URLs to its transformed
schematron object.
|
void |
setModelVersion(java.lang.String modelVersion) |
void |
setSchema(java.util.List<java.net.URL> schemaFiles)
Pass in a list of schemas to validate against.
|
void |
setSchemaCheck(java.lang.Boolean value) |
void |
setSchemaCheck(java.lang.Boolean value,
java.lang.Boolean useLabelSchema) |
void |
setSchematronCheck(java.lang.Boolean value) |
void |
setSchematronCheck(java.lang.Boolean value,
java.lang.Boolean useLabelSchematron) |
void |
setSchematronFiles(java.util.List<java.net.URL> schematronFiles)
Pass in a list of schematron files to validate against.
|
void |
setSchematrons(java.util.List<javax.xml.transform.Transformer> schematrons)
Pass in a list of transformed schematrons to validate
against.
|
void |
validate(java.io.File labelFile) |
void |
validate(ProblemHandler handler,
java.io.File labelFile) |
void |
validate(ProblemHandler handler,
java.net.URL url)
Validates the label against schema and schematron constraints.
|
public static final java.lang.String SCHEMA_CHECK
public static final java.lang.String SCHEMATRON_CHECK
public LabelValidator() throws javax.xml.parsers.ParserConfigurationException, javax.xml.transform.TransformerConfigurationException
javax.xml.parsers.ParserConfigurationException
- If there was an error setting up
the configuration of the parser that is reposnible for doing the
label validation.javax.xml.transform.TransformerConfigurationException
- If there was an error setting
up the Transformer responsible for doing the transformations of the
schematrons.public void setSchema(java.util.List<java.net.URL> schemaFiles)
schemaFiles
- A list of schema URLs.public void setSchematrons(java.util.List<javax.xml.transform.Transformer> schematrons)
schematrons
- A list of transformed schematrons.public void setLabelSchematrons(java.util.Map<java.lang.String,javax.xml.transform.Transformer> schematronMap)
schematronMap
- public void setSchematronFiles(java.util.List<java.net.URL> schematronFiles)
schematronFiles
- A list of schematron URLs.public void setCatalogs(java.lang.String[] catalogFiles)
catalogFiles
- public XMLCatalogResolver getCatalogResolver()
public void validate(ProblemHandler handler, java.io.File labelFile) throws org.xml.sax.SAXException, java.io.IOException, javax.xml.parsers.ParserConfigurationException, javax.xml.transform.TransformerException, MissingLabelSchemaException
org.xml.sax.SAXException
java.io.IOException
javax.xml.parsers.ParserConfigurationException
javax.xml.transform.TransformerException
MissingLabelSchemaException
public void validate(ProblemHandler handler, java.net.URL url) throws org.xml.sax.SAXException, java.io.IOException, javax.xml.parsers.ParserConfigurationException, javax.xml.transform.TransformerException, MissingLabelSchemaException
handler
- a handler to receive errors during the validationurl
- label to validateorg.xml.sax.SAXException
- if there are parsing exceptionsjava.io.IOException
- if there are I/O errors during the parsejavax.xml.parsers.ParserConfigurationException
- if the parser configuration is
invalidjavax.xml.transform.TransformerException
- if there is an error during Schematron
transformationMissingLabelSchemaException
- if the label schema cannot be foundpublic org.w3c.dom.Document parseAndValidate(ProblemHandler handler, java.net.URL url) throws org.xml.sax.SAXException, java.io.IOException, javax.xml.parsers.ParserConfigurationException, javax.xml.transform.TransformerException, MissingLabelSchemaException
handler
- an problem handler to receive errors during the
validationurl
- the URL of the label to validateorg.xml.sax.SAXException
- if there are parsing exceptionsjava.io.IOException
- if there are I/O errors during the parsejavax.xml.parsers.ParserConfigurationException
- if the parser configuration is invalidjavax.xml.transform.TransformerException
- if there is an error during Schematron transformationMissingLabelSchemaException
- if the label schema cannot be foundpublic void validate(java.io.File labelFile) throws org.xml.sax.SAXException, java.io.IOException, javax.xml.parsers.ParserConfigurationException, javax.xml.transform.TransformerException, MissingLabelSchemaException
org.xml.sax.SAXException
java.io.IOException
javax.xml.parsers.ParserConfigurationException
javax.xml.transform.TransformerException
MissingLabelSchemaException
public java.util.List<java.lang.String> getSchematrons(org.w3c.dom.NodeList nodeList, java.net.URL url, ProblemHandler handler)
public java.lang.String getModelVersion()
public void setModelVersion(java.lang.String modelVersion) throws ValidatorException
ValidatorException
public java.lang.Boolean performsSchemaValidation()
public void setSchemaCheck(java.lang.Boolean value)
public void setSchemaCheck(java.lang.Boolean value, java.lang.Boolean useLabelSchema)
public java.lang.Boolean performsSchematronValidation()
public void setSchematronCheck(java.lang.Boolean value)
public void setSchematronCheck(java.lang.Boolean value, java.lang.Boolean useLabelSchematron)
public java.lang.Boolean getConfiguration(java.lang.String key)
public void setConfiguration(java.lang.String key, java.lang.Boolean value)
public void addValidator(ExternalValidator validator)
public void addValidator(DocumentValidator validator)
public void setCachedEntityResolver(CachedEntityResolver resolver)
public void setCachedLSResourceResolver(CachedLSResourceResolver resolver)
public static void main(java.lang.String[] args) throws java.lang.Exception
java.lang.Exception
Copyright © 2010-2018 Planetary Data System. All Rights Reserved.