Search in sources :

Example 1 with TemplateElementDroppingSchemaWrapper

use of nu.validator.xml.templateelement.TemplateElementDroppingSchemaWrapper in project validator by validator.

the class SimpleDocumentValidator method setUpMainSchema.

/* *
     * Prepares the main RelaxNG schema to use for document validation, by
     * retrieving a serialized schema instance from the copies of known
     * http://s.validator.nu/* schemas in the local entity cache packaged with
     * the validator code and creating a Schema instance from it. Also checks
     * for resolution of secondary schemas.
     * 
     * @param schemaUrl an http://s.validator.nu/* URL
     * 
     * @param errorHandler error handler for schema-error reporting
     * 
     * @throws SchemaReadException if retrieval of any schema fails
     */
public void setUpMainSchema(String schemaUrl, ErrorHandler errorHandler) throws SAXException, Exception, SchemaReadException {
    Schema schema = schemaByUrl(schemaUrl, errorHandler);
    if (schemaUrl.contains("html5")) {
        try {
            assertionSchema = CheckerSchema.ASSERTION_SCH;
        } catch (Exception e) {
            throw new SchemaReadException("Failed to retrieve secondary schema.");
        }
        schema = new DataAttributeDroppingSchemaWrapper(schema);
        schema = new XmlLangAttributeDroppingSchemaWrapper(schema);
        schema = new RoleAttributeFilteringSchemaWrapper(schema);
        schema = new TemplateElementDroppingSchemaWrapper(schema);
        schema = new NamespaceChangingSchemaWrapper(schema);
        this.hasHtml5Schema = true;
        if ("http://s.validator.nu/html5-all.rnc".equals(schemaUrl)) {
            System.setProperty("nu.validator.schema.rdfa-full", "1");
        } else {
            System.setProperty("nu.validator.schema.rdfa-full", "0");
        }
    }
    this.mainSchemaUrl = schemaUrl;
    this.mainSchema = schema;
}
Also used : CheckerSchema(nu.validator.checker.jing.CheckerSchema) Schema(com.thaiopensource.validate.Schema) XmlLangAttributeDroppingSchemaWrapper(nu.validator.xml.langattributes.XmlLangAttributeDroppingSchemaWrapper) RoleAttributeFilteringSchemaWrapper(nu.validator.xml.roleattributes.RoleAttributeFilteringSchemaWrapper) DataAttributeDroppingSchemaWrapper(nu.validator.xml.dataattributes.DataAttributeDroppingSchemaWrapper) SAXException(org.xml.sax.SAXException) ResourceNotRetrievableException(nu.validator.xml.PrudentHttpEntityResolver.ResourceNotRetrievableException) IOException(java.io.IOException) FatalSAXException(nu.validator.gnu.xml.aelfred2.FatalSAXException) SAXParseException(org.xml.sax.SAXParseException) TemplateElementDroppingSchemaWrapper(nu.validator.xml.templateelement.TemplateElementDroppingSchemaWrapper) NamespaceChangingSchemaWrapper(nu.validator.xml.customelements.NamespaceChangingSchemaWrapper)

Aggregations

Schema (com.thaiopensource.validate.Schema)1 IOException (java.io.IOException)1 CheckerSchema (nu.validator.checker.jing.CheckerSchema)1 FatalSAXException (nu.validator.gnu.xml.aelfred2.FatalSAXException)1 ResourceNotRetrievableException (nu.validator.xml.PrudentHttpEntityResolver.ResourceNotRetrievableException)1 NamespaceChangingSchemaWrapper (nu.validator.xml.customelements.NamespaceChangingSchemaWrapper)1 DataAttributeDroppingSchemaWrapper (nu.validator.xml.dataattributes.DataAttributeDroppingSchemaWrapper)1 XmlLangAttributeDroppingSchemaWrapper (nu.validator.xml.langattributes.XmlLangAttributeDroppingSchemaWrapper)1 RoleAttributeFilteringSchemaWrapper (nu.validator.xml.roleattributes.RoleAttributeFilteringSchemaWrapper)1 TemplateElementDroppingSchemaWrapper (nu.validator.xml.templateelement.TemplateElementDroppingSchemaWrapper)1 SAXException (org.xml.sax.SAXException)1 SAXParseException (org.xml.sax.SAXParseException)1