public void endElement() { openElements--; XMLElement e = parser.getCurrentElement(); String ns = e.getNamespace(); String name = e.getName(); if (openElements == 0) { report.info(path, FeatureEnum.CHARS_COUNT, Long.toString(charsCount)); if (!epubTypeInUse) { if (context.version == EPUBVersion.VERSION_3) { report.message(MessageId.ACC_007, EPUBLocation.create(path)); } } else { epubTypeInUse = false; } } ElementLocation currentLocation = elementLocationStack.pop(); if (EpubConstants.HtmlNamespaceUri.equals(ns)) { if ("script".equals(name)) { String attr = e.getAttribute("type"); report.info(path, FeatureEnum.HAS_SCRIPTS, (attr == null) ? "" : attr); } else if ("style".equals(name)) { String style = textNode.toString(); if (style.length() > 0) { CSSCheckerFactory.getInstance() .newInstance(context, style, currentLocation.getLineNumber(), false) .runChecks(); } textNode = null; } else if ("head".equals(name)) { checkStylesheetFallback(); } else if ("table".equals(name)) { if (tableDepth > 0) { --tableDepth; EPUBLocation location = EPUBLocation.create( path, currentLocation.getLineNumber(), currentLocation.getColumnNumber(), "table"); checkDependentCondition(MessageId.ACC_005, tableDepth == 0, hasTh, location); checkDependentCondition(MessageId.ACC_006, tableDepth == 0, hasThead, location); checkDependentCondition(MessageId.ACC_012, tableDepth == 0, hasCaption, location); hasTh = hasThead = hasCaption = false; } } } }
protected void checkHRef(XMLElement e, String attrNS, String attr) { String href = e.getAttributeNS(attrNS, attr); if (href == null) { return; } href = href.trim(); if (href.isEmpty()) { // if href="" then selfreference which is valid, // but as per issue 225, issue a hint report.message( MessageId.HTM_045, EPUBLocation.create(path, parser.getLineNumber(), parser.getColumnNumber(), href)); return; } else if (href.contains("#epubcfi")) { return; // temp until cfi implemented } else if (".".equals(href)) { // selfreference, no need to check return; } URI uri = checkURI(href); if (uri == null) return; if ("http".equals(uri.getScheme())) { report.info(path, FeatureEnum.REFERENCE, href); } /* * mgy 20120417 adding check for base to initial if clause as part of * solution to issue 155 */ if (URISchemes.contains(uri.getScheme()) || (null != base && URISchemes.contains(base.getScheme()))) { return; } // This if statement is needed to make sure XML Fragment identifiers // are not reported as non-registered URI scheme types else if (uri.getScheme() != null) { report.message( MessageId.HTM_025, EPUBLocation.create(path, parser.getLineNumber(), parser.getColumnNumber(), href)); return; } try { href = PathUtil.resolveRelativeReference(path, href, base == null ? null : base.toString()); } catch (IllegalArgumentException err) { report.message( MessageId.OPF_010, EPUBLocation.create(path, parser.getLineNumber(), parser.getColumnNumber(), href), err.getMessage()); return; } processHyperlink(href); }