Package com.thaiopensource.util

Examples of com.thaiopensource.util.PropertyMapBuilder


     */
    public boolean doValidation(InputStream schema,
        String xmlFileName,
        OutputStream boust) {
  ErrorHandlerImpl eh = new ErrorHandlerImpl(System.out);
  PropertyMapBuilder properties = new PropertyMapBuilder();
  ValidateProperty.ERROR_HANDLER.put(properties, eh);
  RngProperty.CHECK_ID_IDREF.add(properties);
  SchemaReader sr = null;

  // Simulate -i option, since without the program barfs on
  // Oasis Open Document nrg.
  properties.put(RngProperty.CHECK_ID_IDREF, null);

  boolean hadError = false;
  try {
      ValidationDriver driver = new ValidationDriver(properties.toPropertyMap(), sr);
      InputSource in = new InputSource(schema);
      if (driver.loadSchema(in)) {

    if (!driver.validate(ValidationDriver.uriOrFileInputSource(xmlFileName)))
        hadError = true;
View Full Code Here


        contentTypeParser = new ContentTypeParser(errorHandler, laxType);
        entityResolver = new LocalCacheEntityResolver(dataRes);
        setAllowRnc(true);
        try {
            this.errorHandler.start(document);
            PropertyMapBuilder pmb = new PropertyMapBuilder();
            pmb.put(ValidateProperty.ERROR_HANDLER, errorHandler);
            pmb.put(ValidateProperty.ENTITY_RESOLVER, entityResolver);
            pmb.put(ValidateProperty.XML_READER_CREATOR,
                    new VerifierServletXMLReaderCreator(errorHandler,
                            entityResolver));
            pmb.put(ValidateProperty.SCHEMA_RESOLVER, this);
            RngProperty.CHECK_ID_IDREF.add(pmb);
            jingPropertyMap = pmb.toPropertyMap();

            tryToSetupValidator();

            setAllowRnc(false);
View Full Code Here

            throw new RuntimeException(e);
        }
    }

    private Schema schemaByFilename(File name) throws Exception {
        PropertyMapBuilder pmb = new PropertyMapBuilder();
        pmb.put(ValidateProperty.ERROR_HANDLER, errorHandler);
        pmb.put(ValidateProperty.XML_READER_CREATOR,
                new Jaxp11XMLReaderCreator());
        RngProperty.CHECK_ID_IDREF.add(pmb);
        PropertyMap jingPropertyMap = pmb.toPropertyMap();

        InputSource schemaInput;
        try {
            schemaInput = new InputSource(name.toURL().toString());
        } catch (MalformedURLException e1) {
View Full Code Here

     * @throws SAXNotSupportedException
     * @throws SAXdException
     *
     */
    private void setup(ErrorHandler eh) throws SAXException {
        PropertyMapBuilder pmb = new PropertyMapBuilder();
        pmb.put(ValidateProperty.ERROR_HANDLER, eh);
        pmb.put(ValidateProperty.XML_READER_CREATOR,
                new Jaxp11XMLReaderCreator());
        RngProperty.CHECK_ID_IDREF.add(pmb);
        PropertyMap jingPropertyMap = pmb.toPropertyMap();

        validator = mainSchema.createValidator(jingPropertyMap);
        Validator assertionValidator = assertionSchema.createValidator(jingPropertyMap);
        validator = new CombineValidator(validator, assertionValidator);
        validator = new CombineValidator(validator, new CheckerValidator(
View Full Code Here

    /**
     *
     */
    public static String validate(File schema, File xml) throws Exception {
        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;
            } else {
View Full Code Here

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

     * @throws SAXException if an error occurred creating the validation handler.
     */
    public ValidationHandler createValidator(ErrorHandler errorHandler)
    throws SAXException {
        if (errorHandler == null) errorHandler = DraconianErrorHandler.INSTANCE;
        final PropertyMapBuilder builder = new PropertyMapBuilder();
        ValidateProperty.ERROR_HANDLER.put(builder, errorHandler);
        final PropertyMap properties = builder.toPropertyMap();
        final Validator validator = this.schema.createValidator(properties);
        final ContentHandler handler = validator.getContentHandler();
        return new DefaultValidationHandler(this.getValidity(), handler);
    }
View Full Code Here

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

     * @throws SAXException if an error occurred creating the validation handler.
     */
    public ValidationHandler createValidator(ErrorHandler errorHandler)
    throws SAXException {
        if (errorHandler == null) errorHandler = DraconianErrorHandler.INSTANCE;
        final PropertyMapBuilder builder = new PropertyMapBuilder();
        ValidateProperty.ERROR_HANDLER.put(builder, errorHandler);
        final PropertyMap properties = builder.toPropertyMap();
        final Validator validator = this.schema.createValidator(properties);
        final ContentHandler handler = validator.getContentHandler();
        return new DefaultValidationHandler(this.getValidity(), handler);
    }
View Full Code Here

    /**
     *
     */
    public static String validate(File schema, File xml) throws Exception {
        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;
            } else {
View Full Code Here

TOP

Related Classes of com.thaiopensource.util.PropertyMapBuilder

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.