Search in sources :

Example 1 with XmlLangAttributeDroppingSchemaWrapper

use of nu.validator.xml.langattributes.XmlLangAttributeDroppingSchemaWrapper in project validator by validator.

the class ValidationWorker method main.

public static void main(String[] args) throws Exception {
    BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(args[0]), "utf-8"));
    PrintWriter out = new PrintWriter(new OutputStreamWriter(new GZIPOutputStream(new FileOutputStream(args[1])), "utf-8"), true);
    File rootDir = new File(args[2]);
    Set<Schema> schemas = new HashSet<Schema>();
    schemas.add(CheckerSchema.ASSERTION_SCH);
    schemas.add(CheckerSchema.NORMALIZATION_CHECKER);
    schemas.add(CheckerSchema.TABLE_CHECKER);
    schemas.add(CheckerSchema.TEXT_CONTENT_CHECKER);
    schemas.add(CheckerSchema.USEMAP_CHECKER);
    InputSource is = new InputSource((new File(args[3])).toURL().toExternalForm());
    SchemaReader sr = CompactSchemaReader.getInstance();
    schemas.add(new XmlLangAttributeDroppingSchemaWrapper(new DataAttributeDroppingSchemaWrapper(sr.createSchema(is, PropertyMap.EMPTY))));
    CountingReadLine countingReadLine = new CountingReadLine(in);
    for (int i = 0; i < 4; i++) {
        (new Thread(new ValidationWorker(countingReadLine, out, rootDir, schemas))).start();
    }
}
Also used : InputSource(org.xml.sax.InputSource) CompactSchemaReader(com.thaiopensource.validate.rng.CompactSchemaReader) SchemaReader(com.thaiopensource.validate.SchemaReader) InputStreamReader(java.io.InputStreamReader) Schema(com.thaiopensource.validate.Schema) CheckerSchema(org.whattf.checker.jing.CheckerSchema) XmlLangAttributeDroppingSchemaWrapper(nu.validator.xml.langattributes.XmlLangAttributeDroppingSchemaWrapper) DataAttributeDroppingSchemaWrapper(nu.validator.xml.dataattributes.DataAttributeDroppingSchemaWrapper) FileInputStream(java.io.FileInputStream) GZIPOutputStream(java.util.zip.GZIPOutputStream) FileOutputStream(java.io.FileOutputStream) BufferedReader(java.io.BufferedReader) OutputStreamWriter(java.io.OutputStreamWriter) File(java.io.File) PrintWriter(java.io.PrintWriter) HashSet(java.util.HashSet)

Example 2 with XmlLangAttributeDroppingSchemaWrapper

use of nu.validator.xml.langattributes.XmlLangAttributeDroppingSchemaWrapper 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)2 DataAttributeDroppingSchemaWrapper (nu.validator.xml.dataattributes.DataAttributeDroppingSchemaWrapper)2 XmlLangAttributeDroppingSchemaWrapper (nu.validator.xml.langattributes.XmlLangAttributeDroppingSchemaWrapper)2 SchemaReader (com.thaiopensource.validate.SchemaReader)1 CompactSchemaReader (com.thaiopensource.validate.rng.CompactSchemaReader)1 BufferedReader (java.io.BufferedReader)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1 OutputStreamWriter (java.io.OutputStreamWriter)1 PrintWriter (java.io.PrintWriter)1 HashSet (java.util.HashSet)1 GZIPOutputStream (java.util.zip.GZIPOutputStream)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 RoleAttributeFilteringSchemaWrapper (nu.validator.xml.roleattributes.RoleAttributeFilteringSchemaWrapper)1