String notFound = "<h1>Document not found</h1>"; xr = XMLResource.load(new StringReader(notFound));
xr = getNotFoundDocument(uri);
    public XMLResource getXMLResource(String uri) {        uri = resolveURI(uri);        if (uri != null && uri.startsWith("file:")) {            File file = null;            try {                file = new File(new URI(uri));            } catch (URISyntaxException e) {                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.            }            if (file.isDirectory()) {                String dirlist = DirectoryLister.list(file);                return XMLResource.load(new StringReader(dirlist));            }        }        XMLResource xr = null;        try {            URLConnection uc = new URL(uri).openConnection();            uc.connect();            String contentType = uc.getContentType();            //Maybe should popup a choice when content/unknown!            if (contentType.equals("text/plain") || contentType.equals("content/unknown")) {                //sorry, mucking about a bit here - tobe                SAXSource source = new SAXSource(new PlainTextXMLReader(uc.getInputStream()), new InputSource());                xr = XMLResource.load(source);            } else if (contentType.startsWith("image")) {                String doc = "<img src='" + uri + "'/>";                xr = XMLResource.load(new StringReader(doc));            } else                xr = XMLResource.load(uc.getInputStream());        } catch (MalformedURLException e) {            XRLog.exception("bad URL given: " + uri, e);        } catch (IOException e) {            XRLog.exception("IO problem for " + uri, e);        }        if (xr == null) {            String notFound = "<h1>Document not found</h1>";            xr = XMLResource.load(new StringReader(notFound));        }        return xr;    }