public final class RelaxNGValidator extends Object
| Constructor and Description |
|---|
RelaxNGValidator(URL rngSchemaURL)
Constructs a validator using the supplied schema reference and a default
resource resolver (which will suffice for commonly used URL protocols
such as the
file and http schemes). |
RelaxNGValidator(URL rngSchemaURL,
LSResourceResolver resolver)
Constructs a validator using the supplied schema reference and resource
resolver.
|
| Modifier and Type | Method and Description |
|---|---|
(package private) Schema |
createRelaxNGSchema(URL schemaURL,
LSResourceResolver resolver)
Creates a Schema object from the supplied URL reference.
|
ValidationErrorHandler |
getErrorHandler()
Returns the error handler.
|
(package private) boolean |
isXMLStream(BufferedInputStream bufStream)
A utility method that attempts to determine if the given stream contains
XML content.
|
(package private) static StreamSource |
toStreamSource(DOMSource domSource)
Converts a DOMSource object to a StreamSource.
|
void |
validate(Source source)
Validates the given XML resource against the schema known to this
validator.
|
public RelaxNGValidator(URL rngSchemaURL) throws SAXException, IOException
file and http schemes).rngSchemaURL - An absolute URL that refers to a RELAX NG grammar.IOException - If the schema cannot be accessed.SAXException - If parsing of the schema fails for any reason.public RelaxNGValidator(URL rngSchemaURL, LSResourceResolver resolver) throws SAXException, IOException
rngSchemaURL - A URL that refers to a RELAX NG grammar.resolver - The resolver used to locate external resources (included
grammars) while parsing schemas.SAXException - If the schema cannot be accessed (e.g. URL resolution fails).IOException - If parsing of the schema fails for any reason (e.g. it's not
a valid Relax NG grammar).public ValidationErrorHandler getErrorHandler()
public void validate(Source source) throws SAXException, IOException
source - The Source to be read. It must not be null.SAXException - if a fatal error occurs while parsing the source.IOException - if an error occurs while reading the source.Schema createRelaxNGSchema(URL schemaURL, LSResourceResolver resolver) throws SAXException, IOException
schemaURL - A URL that specifies the location of a Relax NG grammar (XML
or compact syntax).resolver - The resolver used to locate external resources while parsing
schemas.null if one could not be
constructed.IOException - If the grammar cannot be accessed.SAXException - If the grammar cannot be parsed.boolean isXMLStream(BufferedInputStream bufStream)
bufStream - The BufferedInputStream to read.static StreamSource toStreamSource(DOMSource domSource)
domSource - A DOMSource instance.Copyright © 2016 Open Geospatial Consortium. All rights reserved.