Class XmlSchemaValidator
java.lang.Object
org.projecthusky.validation.service.schema.XmlSchemaValidator
An XML Schema validator.
It's thread safe.
- Author:
- Quentin Ligier
-
Constructor Summary
ConstructorsConstructorDescriptionXmlSchemaValidator
(byte[] schema) Constructor.XmlSchemaValidator
(File schema) Constructor.XmlSchemaValidator
(Source schema) Constructor.XmlSchemaValidator
(Source schema, boolean allowDtd, boolean allowInclude, @Nullable LSResourceResolver resourceResolver) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionValidates the XML content with the XML Schema.
-
Constructor Details
-
XmlSchemaValidator
public XmlSchemaValidator(Source schema, boolean allowDtd, boolean allowInclude, @Nullable LSResourceResolver resourceResolver) throws SAXException Constructor.- Parameters:
schema
- The source of the XML Schema to use.allowDtd
- Whether external DTDs and entities can be accessed or not.allowInclude
- Whether includes are resolved or not.resourceResolver
- The custom resource resolver ornull
.- Throws:
SAXException
- if an error arises while parsing the XML Schema.
-
XmlSchemaValidator
Constructor.- Parameters:
schema
- The source of the XML Schema to use.- Throws:
SAXException
- if an error arises while parsing the XML Schema.
-
XmlSchemaValidator
Constructor.- Parameters:
schema
- The content of the XML Schema to use.- Throws:
SAXException
- if an error arises while parsing the XML Schema.
-
XmlSchemaValidator
Constructor.- Parameters:
schema
- The XML Schema file to use.- Throws:
SAXException
- if an error arises while parsing the XML Schema.
-
-
Method Details
-
validate
Validates the XML content with the XML Schema. You can useSources
to convert different objects toSource
s.- Parameters:
xml
- The source of the XML content to validate.- Returns:
- the validation report.
- Throws:
IOException
- if the validator is processing aSAXSource
and the underlyingXMLReader
throws anIOException
.SAXException
- if theErrorHandler
throws aSAXException
or if a fatal error is found and theErrorHandler
returns normally.
-