Commit d72c7f06 authored by Dr. Martin Goik's avatar Dr. Martin Goik

Cosmetics

parent ba3c93e2
......@@ -24,4 +24,4 @@
</tbody>
</table>
</body>
</html>
</html>
\ No newline at end of file
......@@ -11,13 +11,13 @@ import org.jdom2.input.SAXBuilder;
import org.jdom2.xpath.XPathExpression;
import org.jdom2.xpath.XPathFactory;
/**
/**
* Checking external images accessibility
*/
class CheckExtImage {
private final SAXBuilder builder = new SAXBuilder();
/**
/**
* Read a HTML document and search for images. The image filenames will be
* written to standard out.
* @param htmlFilename The XHTML's filename to be examined.
......@@ -26,25 +26,27 @@ class CheckExtImage {
*/
void process(final String htmlFilename) throws JDOMException, IOException {
final Document htmlInput = builder.build(htmlFilename);
final Document htmlInput = builder.build(htmlFilename);
final Namespace htmlNamespace = // Allow for XPath expressions
Namespace.getNamespace("html", // handling HTML name
"http://www.w3.org/1999/xhtml"); // space prefix e.g. h:img
Namespace.getNamespace("html", // handling HTML name
"http://www.w3.org/1999/xhtml"); // space prefix e.g. h:img
final XPathExpression<Element> xpath = XPathFactory.instance().compile (
"//html:img[starts-with(@src, 'http://') or " + // No XPath 2.0 regexp support yet, sigh!
"starts-with(@src, 'https://') or " +
"starts-with(@src, 'ftp://')]",
new ElementFilter(), null, htmlNamespace);
"//html:img[starts-with(@src, 'http://') or " + // No XPath 2.0 regexp support yet, sigh!
"starts-with(@src, 'https://') or " +
"starts-with(@src, 'ftp://')]",
new ElementFilter(),
null /* no search parameter */,
htmlNamespace);
xpath.evaluate(htmlInput).stream().
map(img -> img.getAttributeValue("src")).
forEach(CheckExtImage::printResult);
map(img -> img.getAttributeValue("src")).
forEach(CheckExtImage::printResult);
}
static private void printResult(final String url) {
System.out.println(url
+ ", HTTP Status: " + CheckUrl.checkReadability(url));
}
+ ", HTTP Status: " + CheckUrl.checkReadability(url));
}
}
\ No newline at end of file
......@@ -8,7 +8,7 @@ public class CheckExtImageDriver {
/**
* @param argv Unused cmd argset
* @throws Exception File acces problem or corrupt content.
* @throws Exception File access problem or corrupt content.
*/
public static void main(String[] argv) throws Exception {
final CheckExtImage ao = new CheckExtImage();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment