Package javax.xml.validation

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


            validator.setErrorHandler( baseHandler );

            reader = new XmlStreamReader( file );

            validator.validate( new StreamSource( reader ) );

            return baseHandler;
        }
        catch ( IOException e )
        {
View Full Code Here


        // create a new errorHandler and set it on the validator
        // must be a local instance to avoid problems with concurrency (to be thread safe)
        ValidatorErrorHandler handler = errorHandler.getClass().newInstance();
        validator.setErrorHandler(handler);

        validator.validate(source, result);

        handler.handleErrors(exchange, schema, result);
    }

    public void loadSchema() throws Exception {
View Full Code Here

    Validator validator = schema.newValidator();
    StringReader reader = new StringReader(xml);
    Source source = new StreamSource(reader);
    SchemaValidationResult result = null;
    try {
      validator.validate(source);
      result = new SchemaValidationResult(true, "The xml is valid.");
    } catch (SAXException ex) {
      result = new SchemaValidationResult(false, ex.getMessage());
      log.debug("Validation: " + result);
      log.debug("Cause: " + result.getMessage());
View Full Code Here

            InputStream inputStream = xsdResource.getInputStream();
            Source source = new StreamSource(inputStream);
   
            Schema schema = factory.newSchema(source);
            Validator validator = schema.newValidator();
            validator.validate(new DOMSource(document));
        }
        catch (SAXParseException e) {
            throw new ExecutionException("Error on " + e.getLineNumber() + ", column " + e.getColumnNumber() + " in " + description + ": " + e.getMessage(), e);
        }
        catch (SAXException e) {
View Full Code Here

            InputStream inputStream = xsdResource.getInputStream();
            Source source = new StreamSource(inputStream);
   
            schema = factory.newSchema(source);
            Validator validator = schema.newValidator();
            validator.validate(new DOMSource(document));
        }
        catch (SAXParseException e) {
            throw new ExecutionException("Error on " + e.getLineNumber() + ", column " + e.getColumnNumber() + " in " + description + ": " + e.getMessage(), e);
        }
        catch (SAXException e) {
View Full Code Here

            InputStream inputStream = xsdResource.getInputStream();
            Source source = new StreamSource(inputStream);
   
            Schema schema = factory.newSchema(source);
            Validator validator = schema.newValidator();
            validator.validate(new DOMSource(document));
        }
        catch (SAXParseException e) {
            throw new ExecutionException("Error on " + e.getLineNumber() + ", column " + e.getColumnNumber() + " in " + description + ": " + e.getMessage(), e);
        }
        catch (SAXException e) {
View Full Code Here

            SchemaFactory factory = SchemaFactory.newInstance(language);

            Source source = new DOMSource(map.getSchema());
            Schema schema = factory.newSchema(source);
            Validator validator = schema.newValidator();
            validator.validate(new DOMSource(xml));
            //if no exceptions where raised, the document is valid
            isValid=true;


        } catch(IOException e) {
View Full Code Here

        Validator validator = schema.newValidator();
       
       
        // validate the DOM tree
       
            validator.validate(new DOMSource(document));

        } catch (ParserConfigurationException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            fail();
View Full Code Here

      // create a Validator instance, which can be used to validate an instance document
      Validator validator = schema.newValidator();

     
      // validate the DOM tree
        validator.validate(new DOMSource(document));
        validator.validate(new DOMSource(document2));
       
       
        } catch (ParserConfigurationException e) {
            // TODO Auto-generated catch block
View Full Code Here

      Validator validator = schema.newValidator();

     
      // validate the DOM tree
        validator.validate(new DOMSource(document));
        validator.validate(new DOMSource(document2));
       
       
        } catch (ParserConfigurationException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
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.