Skip to content

Commit 33f2f99

Browse files
committed
fix: do not require the Navigation Document to have an index in an Index Publication
This fix removes the index-specific schemas when checking the Navigation Document. It is probably too simple, a better implementation would only do so if the Nav Doc is not in the spine or is not the only Content Document in the spine, but there is no easy way to check that latter condition in the NavChecker. The fix is a reasonable compromise, as a false-negative (the Nav Doc **must** have index content when it is the unique Content Document) should be pretty rare, and is always better than a false-positive. Fixes #1122
1 parent 177af8f commit 33f2f99

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

src/main/java/com/adobe/epubcheck/nav/NavChecker.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ public class NavChecker implements ContentChecker, DocumentValidator
5050
@SuppressWarnings("unchecked")
5151
private final static ValidatorMap validatorMap = ValidatorMap.builder()
5252
.putAll(XMLValidators.NAV_30_RNC, XMLValidators.XHTML_30_SCH, XMLValidators.NAV_30_SCH)
53-
.putAll(and(Predicates.or(profile(EPUBProfile.EDUPUB), hasPubType(OPFData.DC_TYPE_EDUPUB)),
54-
not(
55-
hasProp(EpubCheckVocab.VOCAB.get(EpubCheckVocab.PROPERTIES.FIXED_LAYOUT))),
53+
.putAll(
54+
and(Predicates.or(profile(EPUBProfile.EDUPUB), hasPubType(OPFData.DC_TYPE_EDUPUB)),
55+
not(hasProp(EpubCheckVocab.VOCAB.get(EpubCheckVocab.PROPERTIES.FIXED_LAYOUT))),
5656
not(hasProp(EpubCheckVocab.VOCAB.get(EpubCheckVocab.PROPERTIES.NON_LINEAR)))),
5757
XMLValidators.XHTML_EDUPUB_STRUCTURE_SCH, XMLValidators.XHTML_EDUPUB_SEMANTICS_SCH,
5858
XMLValidators.XHTML_IDX_SCH)
@@ -61,10 +61,9 @@ public class NavChecker implements ContentChecker, DocumentValidator
6161
mimetype("application/xhtml+xml"), version(EPUBVersion.VERSION_3)),
6262
XMLValidators.XHTML_DICT_SCH)
6363
.putAll(
64-
and(or(profile(EPUBProfile.IDX), hasPubType(OPFData.DC_TYPE_INDEX),
65-
hasProp(PackageVocabs.ITEM_VOCAB.get(PackageVocabs.ITEM_PROPERTIES.INDEX)),
64+
and(or(hasProp(PackageVocabs.ITEM_VOCAB.get(PackageVocabs.ITEM_PROPERTIES.INDEX)),
6665
hasProp(EpubCheckVocab.VOCAB.get(EpubCheckVocab.PROPERTIES.IN_INDEX_COLLECTION))),
67-
mimetype("application/xhtml+xml"), version(EPUBVersion.VERSION_3)),
66+
mimetype("application/xhtml+xml"), version(EPUBVersion.VERSION_3)),
6867
XMLValidators.XHTML_IDX_SCH, XMLValidators.XHTML_IDX_INDEX_SCH)
6968
.build();
7069

src/test/resources/epub-indexes/indexes-publication.feature

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ Feature: EPUB Indexes ▸ Full Publication Checks
2222
When checking EPUB 'index-whole-pub-content-model-error'
2323
Then error RSC-005 is reported
2424
And the message contains 'An "index" must contain one and only one "index-entry-list"'
25-
# FIXME #1122 this error shouldn’t be reported on the Nav Doc
26-
Then error RSC-005 is reported
27-
And the message contains 'At least one "index" element must be present in a document declared as an index in the OPF'
2825
And no other errors or warnings are reported
2926

3027
Scenario: Report a single-file index with an invalid content model
@@ -47,16 +44,12 @@ Feature: EPUB Indexes ▸ Full Publication Checks
4744
Scenario: Verify an index publication
4845
Given EPUBCheck configured with the 'idx' profile
4946
When checking EPUB 'index-whole-pub-valid'
50-
# FIXME #1122 this error shouldn’t be reported on the Nav Doc
51-
Then error RSC-005 is reported
52-
And the message contains 'At least one "index" element must be present in a document declared as an index in the OPF'
5347
And no other errors or warnings are reported
5448

5549
Scenario: Report an index publication without an index
5650
Given EPUBCheck configured with the 'idx' profile
5751
When checking EPUB 'index-whole-pub-no-index-error'
58-
# FIXME #1122 this error shouldn’t be reported on the Nav Doc
59-
Then error RSC-005 is reported 2 times
52+
Then error RSC-005 is reported
6053
And the message contains 'At least one "index" element must be present in a document declared as an index in the OPF'
6154
And no other errors or warnings are reported
6255

0 commit comments

Comments
 (0)