Package com.thaiopensource.validate

Examples of com.thaiopensource.validate.SchemaReader


        InputSource in = ValidationDriver.uriOrFileInputSource(schema.getAbsolutePath());
        PropertyMapBuilder properties = new PropertyMapBuilder();
      ByteArrayOutputStream error = new ByteArrayOutputStream();
        ErrorHandlerImpl eh = new ErrorHandlerImpl(new BufferedWriter(new OutputStreamWriter(error)));
        ValidateProperty.ERROR_HANDLER.put(properties, eh);
        SchemaReader schemaReader = new AutoSchemaReader();
        ValidationDriver driver = new ValidationDriver(properties.toPropertyMap(), schemaReader);
        if (driver.loadSchema(in)) {
            if (driver.validate(ValidationDriver.uriOrFileInputSource(xml.getAbsolutePath()))) {
                log.debug("" + error);
                return null;
View Full Code Here


        InputSource in = ValidationDriver.uriOrFileInputSource(schema.getAbsolutePath());
        PropertyMapBuilder properties = new PropertyMapBuilder();
  ByteArrayOutputStream error = new ByteArrayOutputStream();
        ErrorHandlerImpl eh = new ErrorHandlerImpl(new BufferedWriter(new OutputStreamWriter(error)));
        ValidateProperty.ERROR_HANDLER.put(properties, eh);
        SchemaReader schemaReader = new AutoSchemaReader();
        ValidationDriver driver = new ValidationDriver(properties.toPropertyMap(), schemaReader);
        if (driver.loadSchema(in)) {
            if (driver.validate(ValidationDriver.uriOrFileInputSource(xml.getAbsolutePath()))) {
                System.out.println("" + error);
                return null;
View Full Code Here

            PropertyMapBuilder properties = new PropertyMapBuilder();
            error = new ByteArrayOutputStream();
            ErrorHandlerImpl eh = new ErrorHandlerImpl(
                    new BufferedWriter(new OutputStreamWriter(error)));
            ValidateProperty.ERROR_HANDLER.put(properties, eh);
            SchemaReader schemaReader = new AutoSchemaReader();
            ValidationDriver driver = new ValidationDriver(properties.toPropertyMap(), schemaReader);
            if (driver.loadSchema(schemaInputSource)) {
                if (driver.validate(xmlInputSource)) {
                    log.debug("" + error);
                    return null;
View Full Code Here

            final PropertyMapBuilder properties = new PropertyMapBuilder();
            ValidateProperty.ERROR_HANDLER.put(properties, report);

            // Copied from Jing code ; the Compact syntax seem to have a different
            // Schema reader. To be investigated. http://www.thaiopensource.com/relaxng/api/jing/index.html
            final SchemaReader schemaReader = grammarUrl.endsWith(".rnc") ? CompactSchemaReader.getInstance() : null;

            // Setup driver
            final ValidationDriver driver = new ValidationDriver(properties.toPropertyMap(), schemaReader);

            // Load schema
View Full Code Here

        XdmNode schema = schemaSource.read();
        XdmNode root = S9apiUtils.getDocumentElement(schema);

        docBaseURI = doc.getBaseURI();

        SchemaReader sr = null;

        boolean compact = XProcConstants.c_data.equals(root.getNodeName());

        String contentType = root.getAttributeValue(XProcConstants.c_content_type);
        if (contentType != null) {
View Full Code Here

            // Validate using resource specified in second parameter
            grammar = Shared.getInputSource(args[1].itemAt(0), context);

            // Special setup for compact notation
            final String grammarUrl = grammar.getSystemId();
            final SchemaReader schemaReader
                    = ( (grammarUrl != null) && (grammarUrl.endsWith(".rnc")) )
                    ? CompactSchemaReader.getInstance() : null;

            // Setup validation properties. see Jing interface
            final PropertyMapBuilder properties = new PropertyMapBuilder();
View Full Code Here

        InputSource in = ValidationDriver.uriOrFileInputSource(schema.getAbsolutePath());
        PropertyMapBuilder properties = new PropertyMapBuilder();
      ByteArrayOutputStream error = new ByteArrayOutputStream();
        ErrorHandlerImpl eh = new ErrorHandlerImpl(new BufferedWriter(new OutputStreamWriter(error)));
        ValidateProperty.ERROR_HANDLER.put(properties, eh);
        SchemaReader schemaReader = new AutoSchemaReader();
        ValidationDriver driver = new ValidationDriver(properties.toPropertyMap(), schemaReader);
        if (driver.loadSchema(in)) {
            if (driver.validate(ValidationDriver.uriOrFileInputSource(xml.getAbsolutePath()))) {
                log.debug("" + error);
                return null;
View Full Code Here

    throws SAXException, IOException {
        if (! Validator.GRAMMAR_RELAX_NG.equals(grammar)) {
            throw new IllegalArgumentException("Unsupported grammar " + grammar);
        }

        SchemaReader schemaReader = SAXSchemaReader.getInstance();
        JingResolver context = new JingResolver(sourceResolver, entityResolver);
        InputSource input = context.resolveSource(source);

        try {
            /* Create a simple property map builder */
            PropertyMapBuilder builder = new PropertyMapBuilder();
            ValidateProperty.ENTITY_RESOLVER.put(builder, context);
            ValidateProperty.XML_READER_CREATOR.put(builder, context);
            ValidateProperty.ERROR_HANDLER.put(builder,
                                               DraconianErrorHandler.INSTANCE);
            PropertyMap validatorProperties = builder.toPropertyMap();

            /* Parse, rewrap, and return the schema */
            final com.thaiopensource.validate.Schema schema;
            schema = schemaReader.createSchema(input, validatorProperties);
            return new JingSchema(schema, context.close());

        } catch (IncorrectSchemaException exception) {
            String message = "Incorrect schema \"" + source.getURI() + "\"";
            throw new SAXException(message, exception);
View Full Code Here

        PropertyMap jingPropertyMap = pmb.toPropertyMap();

        try {
            TypedInputSource schemaInput = (TypedInputSource) entityResolver.resolveEntity(
                    null, schemaUrl);
            SchemaReader sr;
            if ("application/relax-ng-compact-syntax".equals(schemaInput.getType())) {
                sr = CompactSchemaReader.getInstance();
            } else {
                sr = new AutoSchemaReader();
            }
            return sr.createSchema(schemaInput, jingPropertyMap);
        } catch (ClassCastException e) {
            throw new SchemaReadException(String.format(
                    "Failed to resolve schema URL \"%s\".", schemaUrl));
        }
    }
View Full Code Here

        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;
        }
View Full Code Here

TOP

Related Classes of com.thaiopensource.validate.SchemaReader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.