Best code examples for Java 8 Schema class (javax.xml.validation.Schema)

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 Schema class.
You can now enable Codota on your own code to easily search and navigate your Java codebase.

Java 8 Schema examples from Open Source projects
This code example shows how to use the following methods: newValidator
        Validator validator = null;
        InputStream xsdStream = SdkAddonConstants.getXsdStream(version);
        if (xsdStream != null) {
            SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
            Schema schema = factory.newSchema(new StreamSource(xsdStream));
            validator = schema.newValidator();
            if (handler != null) {
                validator.setErrorHandler(handler);
            } 
        } 
 
        return validator;
    } 
 
    /** An helper that validates a string against an expected regexp. */ 
    private void assertRegex(String expectedRegexp, String actualString) {
        assertNotNull(actualString);
        assertTrue(
                String.format("Regexp Assertion Failed:\nExpected: %s\nActual: %s\n",
                        expectedRegexp, actualString),
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: newValidator
This code example shows how to use the following methods: newValidator
        dbf.setSchema(schema);
 
        builder = dbf.newDocumentBuilder();
        builder.setErrorHandler(handler);
        builder.setEntityResolver(handler);
        validator = schema.newValidator();
    } 
 
    @Override 
    protected void tearDown() throws Exception { 
        builder = null;
        validator = null;
        super.tearDown(); 
    } 
 
    public void testParserBadXML() { 
        System.out.println("-- testParserBadXML");
        try { 
            builder.parse(getAsStream(BAD_XML));
            assertTrue(true); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: newValidator
    } 
     
    private void validateXML(String xml,java.io.InputStream schemaIn) throws Exception {
    	SchemaFactory sf=SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
    	Schema schema=sf.newSchema(new StreamSource(schemaIn));
    	Validator validator=schema.newValidator();
    	StringBuilder errorBuilder=new StringBuilder();
    	try{ 
    		validator.validate(new StreamSource(new StringReader(xml)));
    	}catch (Exception e) {
    		e.printStackTrace();
    		fail("Error during validation of XML:\n" + e.getLocalizedMessage());
		} 
    } 
 
 
    /** 
     * Explicit RELS-EXT relation to collection object 
     * @throws Exception 
     */ 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: newValidator
            log.debug("Attempt to validate xml at: " + galleryItemUrl + "with xsd at: " + xsdPath);
 
            SchemaFactory schemaFactory = SchemaFactory.newInstance(schemaString);
            Schema schema = schemaFactory.newSchema(new StreamSource(schemaStream));
 
            Validator validator = schema.newValidator();
 
            // TODO: stuff the input stream into the context for execute() 
            InputStream galleryItemInputStream = xmlFetcher.getInputStream(galleryItemUrl);
 
            validator.validate(new StreamSource(galleryItemInputStream));
 
            log.debug("Success validating xml at: " + galleryItemUrl);
        } 
        catch (Exception e)
        { 
            log.error("Validation for gadget definition failed.", e);
            ValidationException ve = new ValidationException();
            ve.addError(URL_KEY, "Valid url is required");
            throw ve;
Full Snippet Info
5
CodeRank
Related Java 8 Schema Questions & Answers:
See Code Examples for Java 8 Schema Methods: