Code example for StreamSource

0
    private Validator validator;
 
    // default 0-arguments constructor 
 
    private Source getAsSource(String xmlString) {
        return new StreamSource(getAsStream(xmlString));
    } 
 
    private InputStream getAsStream(String xmlString) {
        return new ByteArrayInputStream(xmlString.getBytes());
    } 
 
    @Override 
    @Before 
    protected void setUp() throws Exception { 
        super.setUp();         
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        dbf.setValidating(false);
        dbf.setNamespaceAware(true);
        dbf.setXIncludeAware(true);