Class JAXPValidator


  • public class JAXPValidator
    extends Validator
    Validator using the javax.xml.validation namespace.

    An implementation detail of javax.xml.validation.Validator leaks into this class: any xsi:schemaLocation or xsi:noSchemaLocation attribute of the instance document will be ignored if any schema source has been set. This means you must either specify all sources or none of them to successfully validate instances.

    • Field Detail

      • language

        private final java.lang.String language
      • factory

        private final javax.xml.validation.SchemaFactory factory
      • schema

        private javax.xml.validation.Schema schema
    • Constructor Detail

      • JAXPValidator

        public JAXPValidator​(java.lang.String language)
        Creates a validator for the given schema language using the default SchemaFactory.
        Parameters:
        language - the schema language
      • JAXPValidator

        public JAXPValidator​(java.lang.String language,
                             javax.xml.validation.SchemaFactory factory)
        Creates a validator for the given schema language using a custom SchemaFactory.
        Parameters:
        language - the schema language
        factory - the factory to use
    • Method Detail

      • getFactory

        private javax.xml.validation.SchemaFactory getFactory()
      • validateInstance

        public ValidationResult validateInstance​(javax.xml.transform.Source s)
        Description copied from class: Validator
        Validates an instance against the schema.
        Specified by:
        validateInstance in class Validator
        Parameters:
        s - the instance to validate
        Returns:
        result of the validation
      • getSchema

        private javax.xml.validation.Schema getSchema()
                                               throws org.xml.sax.SAXException
        Throws:
        org.xml.sax.SAXException