Code example for StreamSource

Methods: getReader

0
import org.xml.sax.XMLReader; 
 
public class CwrcXmlValidator { 
 
    public Document ValidateDocInUrl(String schemaUrl, String documentUrl, String schemaType) {
        StreamSource document = new StreamSource(documentUrl);
        return Validate(schemaUrl, document.getReader(), schemaType);
    } 
 
    public Document ValidateDocContent(String schemaUrl, String documentContent, String schemaType) {
        documentContent = CharMatcher.WHITESPACE.trimFrom(documentContent);
        //StringReader reader = new StringReader(documentContent); 
        //StreamSource document = new StreamSource(reader); 
        StringReader document = new StringReader(documentContent);
        return Validate(schemaUrl, document, schemaType);
    } 
 
    public Document Validate(String schemaUrl, Reader document, String schemaType) {
        CwrcValidationReport error_report = new CwrcValidationReport();
        CwrcXmlContentHandler content_handler = new CwrcXmlContentHandler();
        CwrcXmlErrorHandler error_handler = new CwrcXmlErrorHandler(error_report, content_handler);