Package com.thaiopensource.validate

Examples of com.thaiopensource.validate.ValidationDriver


        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;
            } else {
                log.error("" + error);
                return "" + error;
View Full Code Here


    }
   
    private static void validateXmlDocumentUsingRng(final String xmlFileName, final String validationFileName)
            throws SAXException, IOException, ApplicationException {
       
        final ValidationDriver validationDriver = new ValidationDriver();
        if (!validationDriver.loadSchema(new InputSource(
                XmlUtils.class.getResourceAsStream("/" + validationFileName)))) {
            throw new ApplicationException("Error during loading RNG schema");
        }
        if (!validationDriver.validate(ValidationDriver.fileInputSource(xmlFileName))) {
            throw new ApplicationException("Error during parsing project file");
        }
    }
View Full Code Here

        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;
            } else {
                return "" + error;
            }
View Full Code Here

            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;
                }
              log.error("" + error);
              return "" + error;
View Full Code Here

            // 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
            driver.loadSchema(new InputSource(grammarUrl));

            // Validate XML instance
            driver.validate(new InputSource(stream));

        } catch(final IOException ex) {
            logger.error(ex);
            report.setThrowable(ex);
View Full Code Here

        while (schemaSource.moreDocuments()) {
            XdmNode schema = schemaSource.read();
            runtime.getResolver().cache(schema, schema.getBaseURI());
        }

        ValidationDriver driver = new ValidationDriver(properties.toPropertyMap());

        InputSource nvdl = S9apiUtils.xdmToInputSource(runtime, nvdldoc);
        InputSource doc = S9apiUtils.xdmToInputSource(runtime, srcdoc);

        try {
            driver.loadSchema(nvdl);

            if (!driver.validate(doc)) {
                if (assertValid) {
                    throw XProcException.stepError(53);
                }
            }
        } catch (SAXException e) {
View Full Code Here

            configurer.configRNG(properties);
            sr = new AutoSchemaReader();
            schemaInputSource = S9apiUtils.xdmToInputSource(runtime, schema);
        }

        ValidationDriver driver = new ValidationDriver(properties.toPropertyMap(), sr);
        try {
            if (driver.loadSchema(schemaInputSource)) {
                InputSource din = S9apiUtils.xdmToInputSource(runtime, doc);
                if (!driver.validate(din)) {
                    if (assertValid) {
                        throw XProcException.stepError(53);
                    }
                }
            } else {
View Full Code Here

            final ExistResolver resolver = new ExistResolver(brokerPool);
            ValidateProperty.URI_RESOLVER.put(properties, resolver);
            ValidateProperty.ENTITY_RESOLVER.put(properties, resolver);

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

            // Load schema
            driver.loadSchema(grammar);

            // Validate XML instance
            driver.validate(instance);
           
        } catch (final MalformedURLException ex) {
            LOG.error(ex.getMessage());
            report.setException(ex);
View Full Code Here

        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;
            } else {
                log.error("" + error);
                return "" + error;
View Full Code Here

    // explicit datatype factory is workaround for Jing bug wrt to OS X
    PropertyMapBuilder properties = new PropertyMapBuilder();
    RngProperty.DATATYPE_LIBRARY_FACTORY.put(properties,
      new DatatypeLibraryFactoryImpl());
   
    ValidationDriver driver = new ValidationDriver(
      properties.toPropertyMap(),
      CompactSchemaReader.getInstance());
   
    InputStream schemaIn = schema.openStream();
    try {
      InputSource schemaSource = new InputSource(schema.openStream());
      schemaSource.setSystemId(schema.toString());
      driver.loadSchema(schemaSource);
      return driver.validate(in);
    } catch (SAXException e) {
      System.out.println(e);
      return false;
    } finally {
      schemaIn.close();
View Full Code Here

TOP

Related Classes of com.thaiopensource.validate.ValidationDriver

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.