Package javax.xml.validation

Examples of javax.xml.validation.Validator.validate()


        }
    }

    void validate(Document doc) throws Exception {
        Validator validator = _xsd.newValidator();
        validator.validate(new DOMSource(doc));
    }
   
    String ior(OpenJPAStateManager sm) {
        return typeOf(sm) + "-" + sm.getObjectId();
    }
View Full Code Here


        // create a new errorHandler and set it on the validator
        errorHandler.reset();
        validator.setErrorHandler(errorHandler);

        DOMResult result = new DOMResult();
        validator.validate(source, result);

        errorHandler.handleErrors(exchange, schema, result);
        /*
         * Fault fault = exchange.createFault(); if (errorHandler.hasErrors()) { //
         * set the schema and source document as properties on the fault
View Full Code Here

                ValidatorErrorHandler handler = errorHandler.getClass().newInstance();
                validator.setErrorHandler(handler);

                try {
                    LOG.trace("Validating {}", source);
                    validator.validate(source, result);
                    handler.handleErrors(exchange, schema, result);
                } catch (SAXParseException e) {
                    // can be thrown for non well formed XML
                    throw new SchemaValidationException(exchange, schema, Collections.singletonList(e),
                            Collections.<SAXParseException>emptyList(),
View Full Code Here

                    LOGGER.error("Error parsing Log4j schema", ex);
                }
                if (schema != null) {
                    final Validator validator = schema.newValidator();
                    try {
                        validator.validate(new StreamSource(new ByteArrayInputStream(buffer)));
                    } catch (final IOException ioe) {
                        LOGGER.error("Error reading configuration for validation", ioe);
                    } catch (final SAXException ex) {
                        LOGGER.error("Error validating configuration", ex);
                    }
View Full Code Here

        Source schemaSource = new StreamSource(filexsd);

        Schema schema = factory.newSchema(schemaSource);
        // validate source xml to xsd
        Validator validator = schema.newValidator();
        validator.validate(new StreamSource(filexml));

        // parse xml to dom
        DocumentBuilder parser = DocumentBuilderFactory.newInstance()
                .newDocumentBuilder();
        Document document = parser.parse(filexml);
View Full Code Here

        Source schemaSource = new StreamSource(filexsd);

        Schema schema = factory.newSchema(schemaSource);
        // validate source xml to xsd
        Validator validator = schema.newValidator();
        validator.validate(new StreamSource(filexml));

        // parse xml to dom
        DocumentBuilder parser = DocumentBuilderFactory.newInstance()
                .newDocumentBuilder();
        Document document = parser.parse(filexml);
View Full Code Here

            Validator validator = schema.newValidator();
            Reporter reporter = new Reporter(url);
            validator.setErrorHandler(reporter);

            // Validate the document
            validator.validate(new StreamSource(url.openStream()));
            return reporter.valid;
         }
         catch (SAXException e)
         {
            log.error("Got a sax exception when doing XSD validation");
View Full Code Here

    }

    List<SAXException> errors = new ArrayList<SAXException>();
    validator.setErrorHandler( new ErrorHandlerImpl( errors ) );
    try {
      validator.validate( new DOMSource( document ) );
    }
    catch (SAXException e) {
      errors.add( e );
    }
    catch (IOException e) {
View Full Code Here

      }
      if (isV1Schema) {
        log.trace("Validate with persistence_1_0.xsd schema on file {}", configURL);
        errors.clear();
        v1Validator.setErrorHandler( new ErrorLogger( errors ) );
        v1Validator.validate( new DOMSource( doc ) );
      }
    }
    if ( errors.size() != 0 ) {
      //report all errors in the exception
      StringBuilder errorMessage = new StringBuilder( );
View Full Code Here

      }
      if (isV1Schema) {
                LOG.trace("Validate with persistence_1_0.xsd schema on file " + configURL);
        errors.clear();
        v1Validator.setErrorHandler( new ErrorLogger( errors ) );
        v1Validator.validate( new DOMSource( doc ) );
      }
    }
    if ( errors.size() != 0 ) {
      //report all errors in the exception
      StringBuilder errorMessage = new StringBuilder( );
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.