Examples of newValidator()


Examples of javax.xml.validation.Schema.newValidator()

            throw new IOException("Could not find schema file for validation.");
        }
        schemaFactory.setResourceResolver(ConfigFilesXmlValidationUtils.JAVAEE_5_LS_RESOURCE_RESOLVER);
        Schema schema = schemaFactory.newSchema(schemaFile);
   
        Validator validator = schema.newValidator();
        URLConnection conn = xmlFile.openConnection();
        conn.setUseCaches(false);
        InputStream is = conn.getInputStream();
        Source source = new StreamSource(is);
        validator.setErrorHandler(VALIDATION_ERROR_HANDLER);
View Full Code Here

Examples of javax.xml.validation.Schema.newValidator()

        xmlSchema = getSchemaFactory().newSchema(xmlSchemaURL);
      } catch(SAXException e) {
            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);
      }
View Full Code Here

Examples of javax.xml.validation.Schema.newValidator()

   public static void validate(final Node node, final String schemaFile) throws Exception
   {
      SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);

      Schema schema = factory.newSchema(findResource(schemaFile));
      Validator validator = schema.newValidator();

      // validate the DOM tree
      try
      {
         validator.validate(new DOMSource(node));
View Full Code Here

Examples of javax.xml.validation.Schema.newValidator()

    SchemaFactory factory = SchemaFactory
        .newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
    Source schemaFile = new StreamSource(xsdFile);
    // log.info("Xsd=" + schemaFile.toString());
    Schema schema = factory.newSchema(schemaFile);
    Validator validator = schema.newValidator();
    try
    {
      validator.validate(new DOMSource(document));
      isValid = true;
    }
View Full Code Here

Examples of javax.xml.validation.Schema.newValidator()

    public ExtendedElement addDefaults() {
        try {
            SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
            URL schemaLocation = ClassLoader.getSystemClassLoader().getResource("testdefinition.xsd");
            Schema schema = factory.newSchema(schemaLocation);
            Validator validator = schema.newValidator();

            DOMSource source = new DOMSource(m_element);
            DOMResult result = new DOMResult();

            validator.validate(source, result);
View Full Code Here

Examples of javax.xml.validation.Schema.newValidator()

                        new StreamSource(xmlSchemaURL.openStream()),
                        new StreamSource(javaeeSchemaURL.openStream())
                });

        // validate
        schema.newValidator().validate(sourceForValidate);
    }
   
    private static URL getSchemaURL(String xsdFileName){
        return JaxbJavaee.class.getClassLoader().getResource("/META-INF/schema/" + xsdFileName);
    }
View Full Code Here

Examples of javax.xml.validation.Schema.newValidator()

    private static void validate(Document doc, String schemaLocation) throws SAXException {
        SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
        // root element has namespace - we can use schema validation
        Schema schema = factory.newSchema(new StreamSource(FeatureValidationUtil.class.getResourceAsStream(schemaLocation)));
        // 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 " + doc.getDocumentURI(), e);
        }
View Full Code Here

Examples of javax.xml.validation.Schema.newValidator()

                log.debug("Schemas have not been specified..");
                schema = factory.newSchema();
            }

            // Setup validator and input source.
            Validator validator = schema.newValidator();
            validator.setErrorHandler(handler);
            validator.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID, true);
            validator.setFeature(HONOUR_ALL_SCHEMA_LOCATIONS_ID, true);

            XMLReader reader = XMLReaderFactory.createXMLReader();
View Full Code Here

Examples of javax.xml.validation.Schema.newValidator()

        // root element has namespace - we can use schema validation
        Schema schema = factory.newSchema(new StreamSource(FeatureValidationUtil.class
            .getResourceAsStream(schemaLocation)));

        // 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 " + doc.getDocumentURI(), e);
View Full Code Here

Examples of javax.xml.validation.Schema.newValidator()

                        // get the value child of the property element
                        Document property = (Document)componentProperty.getValue();
                        Element value = (Element)property.getDocumentElement().getFirstChild();
               
                        // validate the element property/value from the DOM
                        Validator validator = schema.newValidator();
                        validator.validate(new DOMSource(value));
                       
                    } catch (Exception e) {
                        Monitor.error(monitor,
                                this,
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.