Code example for StreamSource

0
            throws SAXException { 
        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),