Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix #457 #734] ACC-008 landmarks issues #735

Merged
merged 4 commits into from
Jun 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.adobe.epubcheck.ctc;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.Hashtable;
Expand Down Expand Up @@ -52,7 +51,6 @@ public boolean validate()
{
boolean result = false;
SearchDictionary vtsd = new SearchDictionary(DictionaryType.VALID_TEXT_MEDIA_TYPES);
int landmarkNavCount = 0;
boolean isGlobalFixed = EpubPackage.isGlobalFixed(this.epubPackage);

Hashtable<String, SpineItem> spineItems = new Hashtable<String, SpineItem>();
Expand Down Expand Up @@ -147,14 +145,8 @@ else if ((0 != (docTypeMatches & hasHTML5)) && ((hasXhtml != (docTypeMatches & h
report.info(null, FeatureEnum.HAS_HTML5, "true");
}
}
landmarkNavCount += sh.getLandmarkNavCount();
}
}
if (landmarkNavCount != 1 && epubPackage.getVersion() == EPUBVersion.VERSION_3)
{
File zipFile = new File(zip.getName());
report.message(MessageId.ACC_008, EPUBLocation.create(zipFile.getName()));
}

return result;
}
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/com/adobe/epubcheck/ctc/EpubNavCheck.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.adobe.epubcheck.ctc;

import java.io.File;
import java.util.HashSet;
import java.util.Vector;
import java.util.zip.ZipEntry;
Expand All @@ -20,6 +21,7 @@
import com.adobe.epubcheck.ctc.epubpackage.SpineItem;
import com.adobe.epubcheck.messages.MessageId;
import com.adobe.epubcheck.opf.DocumentValidator;
import com.adobe.epubcheck.util.EPUBVersion;
import com.adobe.epubcheck.util.EpubConstants;
import com.adobe.epubcheck.util.FeatureEnum;
import com.adobe.epubcheck.util.HandlerUtil;
Expand Down Expand Up @@ -123,6 +125,8 @@ private boolean checkNavDoc(String navDocEntry)
// no need to report an error here because it was already reported inside of the docParser.
return false;
}

int landmarkNavCount = 0;
NodeList n = doc.getElementsByTagName("nav");

for (int i = 0; i < n.getLength(); i++)
Expand Down Expand Up @@ -160,9 +164,18 @@ else if (type.equals("page-list"))
{
report.message(MessageId.NAV_002, EPUBLocation.create(navDocEntry, HandlerUtil.getElementLineNumber(navElement), HandlerUtil.getElementColumnNumber(navElement), "page-list"));
}
else if (type.equals("landmarks"))
{
++landmarkNavCount;
}
}
}

if (landmarkNavCount == 0)
{
report.message(MessageId.ACC_008, EPUBLocation.create(navDocEntry));
}

PackageManifest manifest = epack.getManifest();
PackageSpine spine = epack.getSpine();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,9 @@ else if (("title".compareTo(tagName) == 0) && ("head".compareTo(tagStack.peek())
}
else if ("nav".compareTo(tagName) == 0)
{
String type = attributes.getValue(EpubConstants.EpubTypeNamespaceUri, "type");
if (type != null && "landmark".compareToIgnoreCase(type) == 0)
String epubPrefix = namespaceHelper.findPrefixForUri(EpubConstants.EpubTypeNamespaceUri);
String type = attributes.getValue(epubPrefix+":type");
if (type != null && "landmarks".compareToIgnoreCase(type) == 0)
{
++landmarkNavCount;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"customMessageFileName" : null,
"checker" : {
"path" : "./target/test-classes/com/adobe/epubcheck/test/command_line/failonwarnings.epub",
"path" : "./com/adobe/epubcheck/test/command_line/failonwarnings.epub",
"filename" : "failonwarnings.epub",
"checkerVersion" : "4.0.0-alpha12-SNAPSHOT",
"checkDate" : "03-25-2015 10:06:20",
"elapsedTime" : 62,
"checkerVersion" : "4.0.3-SNAPSHOT",
"checkDate" : "12-31-2016 01:11:58",
"elapsedTime" : 58,
"nFatal" : 0,
"nError" : 0,
"nWarning" : 1,
Expand Down Expand Up @@ -266,7 +266,7 @@
"message" : "Navigation Document has no 'landmarks nav' element.",
"additionalLocations" : 0,
"locations" : [ {
"path" : "failonwarnings.epub",
"path" : "OPS/toc.xhtml",
"line" : -1,
"column" : -1,
"context" : null
Expand Down Expand Up @@ -373,4 +373,4 @@
} ],
"suggestion" : "Every spine item in the manifest should be referenced by at least one NCX entry."
} ]
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"customMessageFileName" : null,
"checker" : {
"path" : "./target/test-classes/com/adobe/epubcheck/test/command_line/jsonfile.epub",
"path" : "./com/adobe/epubcheck/test/command_line/jsonfile.epub",
"filename" : "jsonfile.epub",
"checkerVersion" : "4.0.0-alpha12-SNAPSHOT",
"checkDate" : "03-25-2015 10:06:20",
"elapsedTime" : 58,
"checkerVersion" : "4.0.3-SNAPSHOT",
"checkDate" : "12-31-2016 18:59:12",
"elapsedTime" : 39,
"nFatal" : 0,
"nError" : 0,
"nWarning" : 0,
Expand Down Expand Up @@ -266,7 +266,7 @@
"message" : "Navigation Document has no 'landmarks nav' element.",
"additionalLocations" : 0,
"locations" : [ {
"path" : "jsonfile.epub",
"path" : "OPS/toc.xhtml",
"line" : -1,
"column" : -1,
"context" : null
Expand Down Expand Up @@ -361,4 +361,4 @@
} ],
"suggestion" : "Every spine item in the manifest should be referenced by at least one NCX entry."
} ]
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"customMessageFileName" : null,
"checker" : {
"path" : "./target/test-classes/com/adobe/epubcheck/test/command_line/passonwarnings.epub",
"path" : "./com/adobe/epubcheck/test/command_line/passonwarnings.epub",
"filename" : "passonwarnings.epub",
"checkerVersion" : "4.0.0-alpha12-SNAPSHOT",
"checkDate" : "03-25-2015 10:06:20",
"elapsedTime" : 68,
"checkerVersion" : "4.0.3-SNAPSHOT",
"checkDate" : "12-31-2016 01:11:58",
"elapsedTime" : 39,
"nFatal" : 0,
"nError" : 0,
"nWarning" : 0,
Expand Down Expand Up @@ -266,7 +266,7 @@
"message" : "Navigation Document has no 'landmarks nav' element.",
"additionalLocations" : 0,
"locations" : [ {
"path" : "passonwarnings.epub",
"path" : "OPS/toc.xhtml",
"line" : -1,
"column" : -1,
"context" : null
Expand Down Expand Up @@ -361,4 +361,4 @@
} ],
"suggestion" : "Every spine item in the manifest should be referenced by at least one NCX entry."
} ]
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Start command_line test('severity_overrideBadId')
ERROR(CHK-002): ./com/adobe/epubcheck/test/command_line/severity/(1,0): Unrecognized custom message id BogusID encountered in message overrides file './com/adobe/epubcheck/test/command_line/severity_overrideBadId.txt'.
ERROR(CHK-002): ./com/adobe/epubcheck/test/command_line/severity(1,0): Unrecognized custom message id BogusID encountered in message overrides file './com/adobe/epubcheck/test/command_line/severity_overrideBadId.txt'.
Validating using EPUB version 3.0.1 rules.
USAGE(ACC-007): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/external_css.xhtml(-1,-1): Content Documents do not use 'epub:type' attributes for semantic inflection.
ERROR(CSS-001): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/style_tag_css.xhtml(27,13): The 'unicode-bidi' property must not be included in an EPUB Style Sheet.
Expand All @@ -12,12 +12,12 @@ USAGE(ACC-007): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/inline
ERROR(CSS-001): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/style.css(55,5): The 'unicode-bidi' property must not be included in an EPUB Style Sheet.
ERROR(CSS-001): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/style.css(56,5): The 'direction' property must not be included in an EPUB Style Sheet.
WARNING(CSS-006): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/style.css(66,5): CSS position:fixed property should not be used in EPUBs.
USAGE(ACC-008): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/toc.xhtml(-1,-1): Navigation Document has no 'landmarks nav' element.
USAGE(HTM-010): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/toc.ncx(2,68): Namespace uri 'http://www.daisy.org/z3986/2005/ncx/' was found.
USAGE(OPF-059): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/toc.ncx(-1,-1): Spine item has no NCX entry reference.
USAGE(OPF-059): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/toc.ncx(-1,-1): Spine item has no NCX entry reference.
USAGE(CSS-012): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/external_css.xhtml(6,62): Document links to multiple CSS files.
USAGE(CSS-012): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/external_css.xhtml(7,66): Document links to multiple CSS files.
USAGE(ACC-008): ./com/adobe/epubcheck/test/command_line/severity.epub/severity.epub(-1,-1): Navigation Document has no 'landmarks nav' element.
USAGE(ACC-014): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/style.css(2,5): Value of CSS property 'font-size' does not use a relative size.
USAGE(ACC-014): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/style.css(7,5): Value of CSS property 'font-size' does not use a relative size.
USAGE(ACC-015): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/style.css(7,5): Value of CSS property 'line-height' does not use a relative size.
Expand Down Expand Up @@ -56,23 +56,23 @@ USAGE(ACC-013): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/inline
USAGE(ACC-013): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/inline_css.xhtml(11,97): Content file contains at least one inline style declaration.
USAGE(ACC-013): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/inline_css.xhtml(14,50): Content file contains at least one inline style declaration.
USAGE(ACC-013): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/inline_css.xhtml(15,41): Content file contains at least one inline style declaration.
USAGE(CSS-024): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/unused.css(1,1): CSS class Selector is not used.
USAGE(CSS-024): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/style.css(22,1): CSS class Selector is not used.
USAGE(CSS-024): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/style.css(14,1): CSS class Selector is not used.
USAGE(CSS-024): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/style.css(6,1): CSS class Selector is not used.
USAGE(CSS-024): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/style.css(10,1): CSS class Selector is not used.
USAGE(CSS-024): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/style.css(14,1): CSS class Selector is not used.
USAGE(CSS-024): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/style.css(18,1): CSS class Selector is not used.
USAGE(CSS-024): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/style.css(22,1): CSS class Selector is not used.
USAGE(CSS-024): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/style.css(30,1): CSS class Selector is not used.
USAGE(CSS-024): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/style.css(34,1): CSS class Selector is not used.
USAGE(CSS-024): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/style.css(38,1): CSS class Selector is not used.
USAGE(CSS-024): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/style.css(42,1): CSS class Selector is not used.
USAGE(CSS-024): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/style.css(46,1): CSS class Selector is not used.
USAGE(CSS-024): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/unused.css(30,1): CSS class Selector is not used.
USAGE(CSS-024): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/style.css(6,1): CSS class Selector is not used.
USAGE(CSS-024): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/style.css(30,1): CSS class Selector is not used.
USAGE(CSS-024): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/unused.css(56,1): CSS class Selector is not used.
USAGE(CSS-024): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/style.css(82,1): CSS class Selector is not used.
USAGE(CSS-024): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/unused.css(49,1): CSS class Selector is not used.
USAGE(CSS-024): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/unused.css(36,1): CSS class Selector is not used.
USAGE(CSS-024): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/style.css(98,5): CSS class Selector is not used.
USAGE(CSS-024): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/unused.css(1,1): CSS class Selector is not used.
USAGE(CSS-024): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/unused.css(30,1): CSS class Selector is not used.
USAGE(CSS-024): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/unused.css(36,1): CSS class Selector is not used.
USAGE(CSS-024): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/unused.css(49,1): CSS class Selector is not used.
USAGE(CSS-024): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/unused.css(56,1): CSS class Selector is not used.
USAGE(CSS-024): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/unused.css(62,1): CSS class Selector is not used.
USAGE(CSS-024): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/unused.css(66,3): CSS class Selector is not used.

Expand Down
Loading