Code example for StreamSource

0
        StreamSource source = null;
        if (xml.getCharacterStream() != null) { 
            source = new StreamSource(xml.getCharacterStream());
        } 
        else if (xml.getByteStream() != null) {
            source = new StreamSource(xml.getByteStream());
        } 
        else { 
            throw new IllegalArgumentException("Could not turn input source to stream source");
        } 
        return validate(source, schemaURL, skipTargetNamespaceException);
    } 
 
    public static List validate(Source xml, URL schemaURL, boolean skipTargetNamespaceException) {
        SAXParserFactory factory = SAXParserFactory.newInstance();
        try { 
            Schema schema = 
                SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(schemaURL);
            Validator v = schema.newValidator();
            Handler handler = new Handler(skipTargetNamespaceException);
Contextual code suggestions in your IDE  Get Codota for Java