示例#1
0
 public void startElement() {
   XMLElement e = parser.getCurrentElement();
   String ns = e.getNamespace();
   String name = e.getName();
   String id = e.getAttribute("id");
   if (ns.equals("http://www.daisy.org/z3986/2005/dtbook/")) {
     // link@href, a@href, img@src
     String uri = null;
     /*
      * This section checks to see if the references used are registered
      * schema-types and whether they point to external resources. The
      * resources are only allowed to be external if the attribute
      * "external" is set to true.
      */
     if (name.equals("a")) {
       uri = e.getAttribute("href");
       String external = e.getAttribute("external");
       if (uri != null && external.equals("true")) {
         if (OPSHandler.isRegisteredSchemeType(uri)) uri = null;
         else if (uri.indexOf(':') > 0) {
           parser
               .getReport()
               .warning(
                   path,
                   parser.getLineNumber(),
                   parser.getColumnNumber(),
                   "use of non-registered URI schema type in href: " + uri);
           uri = null;
         }
       }
     } else if (name.equals("link")) {
       uri = e.getAttribute("href");
     } else if (name.equals("img")) {
       uri = e.getAttribute("src");
     }
     if (uri != null) {
       // TODO check if dtbook uses xml:base of so set third param
       uri = PathUtil.resolveRelativeReference(path, uri, null);
       xrefChecker.registerReference(
           path,
           parser.getLineNumber(),
           parser.getColumnNumber(),
           uri,
           name.equals("img") ? XRefChecker.RT_IMAGE : XRefChecker.RT_HYPERLINK);
       if (uri.startsWith("http")) {
         parser.getReport().info(path, FeatureEnum.REFERENCE, uri);
       }
     }
     if (id != null)
       xrefChecker.registerAnchor(
           path, parser.getLineNumber(), parser.getColumnNumber(), id, XRefChecker.RT_HYPERLINK);
   }
 }
示例#2
0
 public void startElement() {
   XMLElement e = parser.getCurrentElement();
   String ns = e.getNamespace();
   String name = e.getName();
   if (ns.equals("http://www.daisy.org/z3986/2005/ncx/")) {
     if (name.equals("content")) {
       String href = e.getAttribute("src");
       if (href != null) {
         href = PathUtil.resolveRelativeReference(path, href, null);
         xrefChecker.registerReference(
             path,
             parser.getLineNumber(),
             parser.getColumnNumber(),
             href,
             XRefChecker.RT_HYPERLINK);
       }
     }
   }
 }