Package javax.xml.validation

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


        // 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));
    }
   
    //method to convert Document to String
    public static String getStringFromDocument(Document doc)
    {
View Full Code Here


            validator.setErrorHandler( baseHandler );

            reader = new XmlStreamReader( file );

            validator.validate( new StreamSource( reader ) );

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

    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;
    }
    return true;
View Full Code Here

            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);
            resource.addProperty(XSD_VALIDATION_ERROR, e.getMessage());
            throw new RegistryException(e.getMessage());
View Full Code Here

                Validator validator = schema.newValidator();

                // debugPrint(rootNode);

                DOMSource domSrc = new DOMSource(rootNode);
                validator.validate(domSrc);
                log.info("Configuration file validated fine.");
            } catch (SAXException e) {
                log.info(e.getMessage());
                log.info("Will try to use configuration anyway.");
            } catch (IOException e) {
View Full Code Here

        URLConnection conn = xmlFile.openConnection();
        conn.setUseCaches(false);
        InputStream is = conn.getInputStream();
        Source source = new StreamSource(is);
        validator.setErrorHandler(VALIDATION_ERROR_HANDLER);
        validator.validate(source);
    }

    private static Source getFacesConfigSchemaFileAsSource(ExternalContext externalContext, String version)
    {
        String xmlSchema = "1.2".equals(version) ? FACES_CONFIG_SCHEMA_PATH_12 : ("2.0".equals(version) ? FACES_CONFIG_SCHEMA_PATH_20 : FACES_CONFIG_SCHEMA_PATH_21) ;
View Full Code Here

        URLConnection conn = xmlFile.openConnection();
        conn.setUseCaches(false);
        InputStream is = conn.getInputStream();
        Source source = new StreamSource(is);
        validator.setErrorHandler(VALIDATION_ERROR_HANDLER);
        validator.validate(source);
    }
   
    private static Source getFaceletSchemaFileAsSource(ExternalContext externalContext)
    {
        InputStream stream = ClassUtils.getResourceAsStream(FACES_TAGLIB_SCHEMA_PATH);
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
            return true;
        } catch(IOException e) {
            e.printStackTrace();
View Full Code Here

    public static void validateSecurityOrEncryptionElement(Node toValidate) throws SAXException, IOException {
       
        Schema schema = XMLSecurityConstants.getJaxbSchemas();
        Validator validator = schema.newValidator();
        DOMSource source = new DOMSource(toValidate);
        validator.validate(source);
    }
   
    public static PrivateKey getPrivateKey(String algo)
        throws InvalidKeySpecException, NoSuchAlgorithmException {
        KeyFactory kf = KeyFactory.getInstance(algo);
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

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.