Search in sources :

Example 1 with CheckerSchema

use of nu.validator.checker.jing.CheckerSchema in project validator by validator.

the class VerifierServletTransaction method resolveSchema.

@Override
public Schema resolveSchema(String url, PropertyMap options) throws SAXException, IOException, IncorrectSchemaException {
    int i = Arrays.binarySearch(preloadedSchemaUrls, url);
    if (i > -1) {
        Schema rv = preloadedSchemas[i];
        if (options.contains(WrapProperty.ATTRIBUTE_OWNER)) {
            if (rv instanceof CheckerSchema) {
                errorHandler.error(new SAXParseException("A non-schema checker cannot be used as an attribute schema.", null, url, -1, -1));
                throw new IncorrectSchemaException();
            } else {
            // ugly fall through
            }
        } else {
            return rv;
        }
    }
    externalSchema = true;
    TypedInputSource schemaInput = (TypedInputSource) entityResolver.resolveEntity(null, url);
    SchemaReader sr = null;
    if ("application/relax-ng-compact-syntax".equals(schemaInput.getType())) {
        sr = CompactSchemaReader.getInstance();
    } else {
        sr = new AutoSchemaReader();
    }
    Schema sch = sr.createSchema(schemaInput, options);
    if (Statistics.STATISTICS != null && "com.thaiopensource.validate.schematron.SchemaImpl".equals(sch.getClass().getName())) {
        externalSchematron = true;
    }
    return sch;
}
Also used : CheckerSchema(nu.validator.checker.jing.CheckerSchema) CompactSchemaReader(com.thaiopensource.validate.rng.CompactSchemaReader) AutoSchemaReader(com.thaiopensource.validate.auto.AutoSchemaReader) SchemaReader(com.thaiopensource.validate.SchemaReader) TypedInputSource(nu.validator.xml.TypedInputSource) AutoSchemaReader(com.thaiopensource.validate.auto.AutoSchemaReader) SAXParseException(org.xml.sax.SAXParseException) Schema(com.thaiopensource.validate.Schema) CheckerSchema(nu.validator.checker.jing.CheckerSchema) IncorrectSchemaException(com.thaiopensource.validate.IncorrectSchemaException)

Aggregations

IncorrectSchemaException (com.thaiopensource.validate.IncorrectSchemaException)1 Schema (com.thaiopensource.validate.Schema)1 SchemaReader (com.thaiopensource.validate.SchemaReader)1 AutoSchemaReader (com.thaiopensource.validate.auto.AutoSchemaReader)1 CompactSchemaReader (com.thaiopensource.validate.rng.CompactSchemaReader)1 CheckerSchema (nu.validator.checker.jing.CheckerSchema)1 TypedInputSource (nu.validator.xml.TypedInputSource)1 SAXParseException (org.xml.sax.SAXParseException)1