diff --git a/P/Sda1/VerifyImgAccess/src/main/java/dom/xpath/CheckExtImage.java b/P/Sda1/VerifyImgAccess/src/main/java/dom/xpath/CheckExtImage.java index 1367135c66ace8889d01dcfa21808afed50004d8..e7f281ea6c340b3fbd8e5d7fc17f05ed8cea7d9d 100644 --- a/P/Sda1/VerifyImgAccess/src/main/java/dom/xpath/CheckExtImage.java +++ b/P/Sda1/VerifyImgAccess/src/main/java/dom/xpath/CheckExtImage.java @@ -18,21 +18,23 @@ public class CheckExtImage { private final SAXBuilder builder = new SAXBuilder(); /** - * Read an XHTML document and search for images. The image filenames will be + * Read a HTML document and search for images. The image filenames will be * written to standard out. - * @param xhtmlFilename The XHTML's filename to be examined. + * @param htmlFilename The XHTML's filename to be examined. * @throws JDOMException General parsing fault * @throws IOException file access problem */ - public void process(final String xhtmlFilename) throws JDOMException, IOException { + public void process(final String htmlFilename) throws JDOMException, IOException { - final Document htmlInput = builder.build(xhtmlFilename); + final Document htmlInput = builder.build(htmlFilename); - final Namespace htmlNamespace = // This will allow for XPath expressions like xhtml:img - Namespace.getNamespace("xhtml", "http://www.w3.org/1999/xhtml"); + final Namespace htmlNamespace = // This will allow XPath + Namespace.getNamespace("h", // expressions handling name + "http://www.w3.org/1999/xhtml"); // spaces by prefixing e.g. h:img final XPathExpression<Element> xpath = XPathFactory.instance().compile ( - "//xhtml:img[starts-with(@src, 'http://') or starts-with(@src, 'https://') or starts-with(@src, 'ftp://')]", + "//h:img[starts-with(@src, 'http://') or "+ + "starts-with(@src, 'https://') or starts-with(@src, 'ftp://')]", new ElementFilter(), null, htmlNamespace); xpath.evaluate(htmlInput).stream(). @@ -40,7 +42,7 @@ public class CheckExtImage { forEach(CheckExtImage::printResult); } - static private void printResult(String url) { + static private void printResult(final String url) { System.out.println(url + ", HTTP Status: " + CheckUrl.checkReadability(url)); }