Package javax.xml.validation

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


    public void validate(Schema schema) {
        try {
            Validator validator = schema.newValidator();
            for (Document doc : this.documents) {
                validator.validate(new DOMSource(doc));
            }
        } catch (Exception e) {
            throw new ComponentDefinitionException("Unable to validate xml", e);
        }
    }
View Full Code Here


        try {
            SAXBuilder builder = new SAXBuilder(false);
            Document doc = builder.build(input);
            if(verifySchema) {
                Validator validator = this.schema.newValidator();
                validator.validate(new JDOMSource(doc));
            }
            Element root = doc.getRootElement();
            if(!root.getName().equals(CLUSTER_ELMT))
                throw new MappingException("Invalid root element: "
                                           + doc.getRootElement().getName());
View Full Code Here

            SAXBuilder builder = new SAXBuilder();
            Document doc = builder.build(input);
            if(verifySchema) {
                Validator validator = schema.newValidator();
                validator.validate(new JDOMSource(doc));
            }
            Element root = doc.getRootElement();
            if(!root.getName().equals(STORES_ELMT))
                throw new MappingException("Invalid root element: "
                                           + doc.getRootElement().getName());
View Full Code Here

                errorHandler = new DefaultValidationErrorHandler();
            }
            Validator validator = schema.newValidator();
            validator.setErrorHandler(errorHandler);
            try {
                validator.validate(source);
                return errorHandler.getErrors();
            }
            catch (SAXException ex) {
                throw new XmlValidationException("Could not validate source: " + ex.getMessage(), ex);
            }
View Full Code Here

            throw XMLPlatformException.xmlPlatformErrorResolvingXMLSchema(xmlSchemaURL, e);       
      }
      try {
        Validator validator = xmlSchema.newValidator();
        validator.setErrorHandler(errorHandler);
        validator.validate(new DOMSource(document));
      } catch(Exception e) {
            throw XMLPlatformException.xmlPlatformValidationException(e);
      }
    return true;
    }
View Full Code Here

      Validator validator = schema.newValidator();

      // validate the DOM tree
      try
      {
         validator.validate(new DOMSource(node));
      }
      catch (SAXException e)
      {
         HornetQClientLogger.LOGGER.errorOnXMLTransformInvalidConf(e);
View Full Code Here

    // log.info("Xsd=" + schemaFile.toString());
    Schema schema = factory.newSchema(schemaFile);
    Validator validator = schema.newValidator();
    try
    {
      validator.validate(new DOMSource(document));
      isValid = true;
    }
    catch (SAXException e)
    {
      log.error("Failed to validate xml", e);
View Full Code Here

    private void validate(final String xml) throws ActionProcessingException
    {
        try
        {
            final Validator validator = schema.newValidator();
            validator.validate(createSourceFromPayload(xml));
        }
        catch (final SAXException e)
        {
            final String errorMsg = "SAXException while trying to validate against schema '" + xsd + "'";
            log.error(errorMsg, e);
View Full Code Here

    public static boolean validate(final Schema schema, final String xml)
    {
        final Validator validator = schema.newValidator() ;
        try
        {
            validator.validate(new StreamSource(new StringReader(xml))) ;
            return true ;
        }
        catch (final IOException ioe)
        {
            log.debug(ioe.getMessage(), ioe);
View Full Code Here

        try {
            Validator validator = cachedSchema.newValidator();
            validator.setErrorHandler(errorHandler);

            // perform actual validation
            validator.validate(validateSrc);

            if (errorHandler.isValidationError()) {

                if (synLog.isTraceOrDebugEnabled()) {
                    String msg = "Validation of element returned by XPath : " + source +
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.