Package javax.xml.validation

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


        // load a WXS schema, represented by a Schema instance
        Source schemaFileSource = new StreamSource(schemaFile);
        Schema schema = factory.newSchema(schemaFileSource);

        // 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));
    }
View Full Code Here


        // load a WXS schema, represented by a Schema instance
        Source schemaFileSource = new StreamSource(schemaFile);
        Schema schema = factory.newSchema(schemaFileSource);

        // 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));
    }
   
View Full Code Here

        Source schemaFile = new StreamSource(new File(pathToRootSchemaFile));
        schemas[0] = schemaFile;
       
        Schema schema = factory.newSchema(schemas);
        // create a Validator instance, which can be used to validate an instance document
        validator = schema.newValidator();

    }

    public void validateDocumentAgainstSchema(Node documentNode) throws SAXException, IOException {
      validator.validate(new DOMSource(documentNode));
View Full Code Here

        {
            String schemaPath = CHANGES_SCHEMA_PATH + "changes-" + schemaVersion + ".xsd";

            Schema schema = getSchema( schemaPath );

            Validator validator = schema.newValidator();

            XmlValidationHandler baseHandler = new XmlValidationHandler( failOnValidationError );

            validator.setErrorHandler( baseHandler );
View Full Code Here

  public static boolean validateResultStructure(OMElement result,
      String schemaPath) throws Exception {
    SchemaFactory fac = SchemaFactory.newInstance(XSD_SCHEMA);
    Source source = new StreamSource(new FileInputStream(schemaPath));
    Schema schema = fac.newSchema(source);
    Validator validator = schema.newValidator();
    try {
      validator.validate(new StreamSource(new StringReader(result
          .toString())));
    } catch (Exception e) {
      return false;
View Full Code Here

            SchemaFactory factory = SchemaFactory.newInstance(W3C_XML_SCHEMA_NS_URI);
            // load a WXS schema, represented by a Schema instance
            Source schemaFile = new StreamSource(xsdContent);
            Schema schema = factory.newSchema(schemaFile);
            // create a Validator instance, which can be used to validate an instance document
            Validator validator = schema.newValidator();
            // validate the DOM tree
            validator.validate(scoure);
            resource.setProperty(XSD_STATUS, XSD_VALID);
        } catch (Exception e) {
            resource.setProperty(XSD_STATUS, XSD_IN_VALID);
View Full Code Here

        dbf.setSchema(schema);

        builder = dbf.newDocumentBuilder();
        builder.setErrorHandler(handler);
        builder.setEntityResolver(handler);
        validator = schema.newValidator();
    }

    @Override
    protected void tearDown() throws Exception {
        builder = null;
View Full Code Here

        SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
        schemaFactory.setFeature("http://apache.org/xml/features/validation/schema-full-checking", true);
        Source muleXsd = new StreamSource(load("META-INF/mule.xsd"));
        Schema schema = schemaFactory.newSchema(muleXsd);
        Source muleRootTestXml = new StreamSource(load("org/mule/test/spring/mule-root-test.xml"));
        schema.newValidator().validate(muleRootTestXml);
    }

    protected InputStream load(String name) throws IOException
    {
        InputStream stream = IOUtils.getResourceAsStream(name, getClass());
View Full Code Here

        try
        {
            SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
            schemaFactory.setFeature("http://apache.org/xml/features/validation/schema-full-checking", true);
            Schema schema = schemaFactory.newSchema(getSchemasAsSources());
            schema.newValidator().validate(load(config));
        }
        catch (SAXParseException ex)
        {
            System.err.println(MessageFormat.format("SAX parsing exception occurs at line {0}, column {1}",
                ex.getLineNumber(), ex.getColumnNumber()));
View Full Code Here

            InputStream is = XMLConfiguration.class.getResourceAsStream("geowebcache.xsd");

            // Parsing the schema file
            try {
                Schema schema = factory.newSchema(new StreamSource(is));
                Validator validator = schema.newValidator();

                // debugPrint(rootNode);

                DOMSource domSrc = new DOMSource(rootNode);
                validator.validate(domSrc);
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.