Package javax.xml.validation

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


        }

        if (doValidate) {
            try {
                Validator v = getMetadataValidator();
                v.validate(new DOMSource(document));
            } catch (SAXException ex) {
                Message msg = new Message("METADATA_VALIDATION_ERROR_EXC", LOG);
                throw new ConfigurationException(msg, ex);
            }
        }
View Full Code Here


            public void warning(SAXParseException exception) throws SAXException {
                throw exception;
            }
        });
        validator.validate(new OMSource(element));
        String pidString = element.getAttributeValue(new QName(SyslogConstants.PID));
        return new SyslogMessage(element.getAttributeValue(new QName(SyslogConstants.FACILITY)),
                                 element.getAttributeValue(new QName(SyslogConstants.SEVERITY)),
                                 element.getAttributeValue(new QName(SyslogConstants.TAG)),
                                 pidString == null ? -1 : Integer.parseInt(pidString),
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

        // create schema by reading it from an XSD file:
        Validator validator = schema.newValidator();

        try {
            validator.validate(new DOMSource(doc));
        } catch (Exception e) {
            throw new IllegalArgumentException("Unable to validate " + uri, e);
        }       
    }
View Full Code Here

        SOAPEnvelope envelope = builder.getSOAPEnvelope();
        OMElement bodyContent = envelope.getBody().getFirstElement();
        SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
        Schema schema = schemaFactory.newSchema(schemaUrl);
        Validator validator = schema.newValidator();
        validator.validate(bodyContent.getSAXSource(true));
    }
    // END SNIPPET: sax
   
    public void testSAX() throws Exception {
        validate(getClass().getResourceAsStream("soap-request.xml"), getClass().getResource("schema.xsd"));
View Full Code Here

        SOAPEnvelope envelope = builder.getSOAPEnvelope();
        OMElement bodyContent = envelope.getBody().getFirstElement();
        SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
        Schema schema = schemaFactory.newSchema(schemaUrl);
        Validator validator = schema.newValidator();
        validator.validate(new DOMSource((Element)bodyContent));
    }
    // END SNIPPET: dom
   
    public void testDOM() throws Exception {
        validate(getClass().getResourceAsStream("soap-request.xml"), getClass().getResource("schema.xsd"));
View Full Code Here

        final Document doc = builder.parse(configFile);

        final DOMSource source = new DOMSource(doc);
        final DOMResult result = new DOMResult();

        validator.validate(source, result);
        Document root = (Document) result.getNode();

        // TargetName
        Configuration returnConfiguration = new Configuration(pTargetAddress);
        Element targetListNode = (Element) root.getElementsByTagName(ELEMENT_TARGET_LIST).item(0);
View Full Code Here

            final Document doc = builder.parse(configFile);

            final DOMSource source = new DOMSource(doc);
            final DOMResult result = new DOMResult();

            validator.validate(source, result);

            return (Document) result.getNode();
        } catch (final SAXException exc) {
            throw new ConfigurationException(exc);
        } catch (final ParserConfigurationException exc) {
View Full Code Here

        try {
            URL schema = Resources.getResource("/catalog.xsd");
            Validator validator = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema").newSchema(schema)
                    .newValidator();
            Source source = new StreamSource(new CharArrayReader(xml.toCharArray()));
            validator.validate(source);
        } catch (Exception e) {
            this.errorHolder.addErrorMessage("Validation Error", e);
            return null;
        }
        // parse file into catalog
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

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.