Skip to content
Snippets Groups Projects
Commit dea0da4d authored by Goik Martin's avatar Goik Martin
Browse files

Comment extension

parent d1406ebc
No related branches found
No related tags found
No related merge requests found
......@@ -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));
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment