Class XmlValidatorFactory
java.lang.Object
org.springframework.xml.validation.XmlValidatorFactory
Factory for
XmlValidator objects, being aware of JAXP 1.3 Validators, and JAXP 1.0 parsing
capabilities. Mainly for internal use within the framework.
The goal of this class is to avoid runtime dependencies on JAXP 1.3 by using the best validation implementation that
is available. Prefers JAXP 1.3 XmlValidator implementations to a custom, SAX-based implementation.
- Since:
- 1.0.0
- Author:
- Arjen Poutsma
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic XmlValidatorcreateValidator(org.springframework.core.io.Resource[] schemaResources, String schemaLanguage) Create aXmlValidatorwith the given schema resources and schema language type.static XmlValidatorcreateValidator(org.springframework.core.io.Resource schemaResource, String schemaLanguage) Create aXmlValidatorwith the given schema resource and schema language type.
-
Field Details
-
SCHEMA_W3C_XML
Constant that defines a W3C XML Schema.- See Also:
-
SCHEMA_RELAX_NG
Constant that defines a RELAX NG Schema.- See Also:
-
-
Constructor Details
-
XmlValidatorFactory
public XmlValidatorFactory()
-
-
Method Details
-
createValidator
public static XmlValidator createValidator(org.springframework.core.io.Resource schemaResource, String schemaLanguage) throws IOException Create aXmlValidatorwith the given schema resource and schema language type. The schema language must be one of theSCHEMA_XXXconstants.- Parameters:
schemaResource- a resource that locates the schema to validate againstschemaLanguage- the language of the schema- Returns:
- a validator
- Throws:
IOException- if the schema resource cannot be readIllegalArgumentException- if the schema language is not supportedIllegalStateException- if JAXP 1.0 cannot be locatedXmlValidationException- if aXmlValidatorcannot be created- See Also:
-
createValidator
public static XmlValidator createValidator(org.springframework.core.io.Resource[] schemaResources, String schemaLanguage) throws IOException Create aXmlValidatorwith the given schema resources and schema language type. The schema language must be one of theSCHEMA_XXXconstants.- Parameters:
schemaResources- an array of resource that locate the schemas to validate againstschemaLanguage- the language of the schemas- Returns:
- a validator
- Throws:
IOException- if the schema resource cannot be readIllegalArgumentException- if the schema language is not supportedIllegalStateException- if JAXP 1.0 cannot be locatedXmlValidationException- if aXmlValidatorcannot be created- See Also:
-