From dea0da4d40a9f8e0a8efc221c8d2a63bf420eecc Mon Sep 17 00:00:00 2001
From: Martin Goik <goik@hdm-stuttgart.de>
Date: Sun, 29 Nov 2015 08:48:52 +0100
Subject: [PATCH] Comment extension

---
 .../src/main/java/dom/xpath/CheckExtImage.java | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

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 1367135c6..e7f281ea6 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));
    }  
-- 
GitLab