From f8a2517ec70cc23061cb4166e901b67d9d058f39 Mon Sep 17 00:00:00 2001 From: Matt Garrish Date: Tue, 1 Sep 2020 09:29:16 -0300 Subject: [PATCH] feat: report unknown 'epub:type' values in overlays as USAGE only (#1171) Matches `epub:type` checking in Media Overlays documents to Content Documents (`USAGE` message for unknown values from structure vocab). --- .../epubcheck/overlay/OverlayHandler.java | 20 ++++++++++++++++--- ...error.smil => epubtype-unknown-usage.smil} | 0 .../epub3/mediaoverlays-smil-document.feature | 8 ++++---- 3 files changed, 21 insertions(+), 7 deletions(-) rename src/test/resources/epub3/files/mediaoverlays-document/{epubtype-unknown-error.smil => epubtype-unknown-usage.smil} (100%) diff --git a/src/main/java/com/adobe/epubcheck/overlay/OverlayHandler.java b/src/main/java/com/adobe/epubcheck/overlay/OverlayHandler.java index 106cfed65..8dc2a1e4f 100644 --- a/src/main/java/com/adobe/epubcheck/overlay/OverlayHandler.java +++ b/src/main/java/com/adobe/epubcheck/overlay/OverlayHandler.java @@ -12,6 +12,8 @@ import com.adobe.epubcheck.util.EpubConstants; import com.adobe.epubcheck.util.HandlerUtil; import com.adobe.epubcheck.util.PathUtil; +import com.adobe.epubcheck.vocab.Property; +import com.adobe.epubcheck.vocab.AggregateVocab; import com.adobe.epubcheck.vocab.StructureVocab; import com.adobe.epubcheck.vocab.Vocab; import com.adobe.epubcheck.vocab.VocabUtil; @@ -25,10 +27,10 @@ public class OverlayHandler implements XMLHandler { private static Map RESERVED_VOCABS = ImmutableMap. of("", - StructureVocab.VOCAB); + AggregateVocab.of(StructureVocab.VOCAB, StructureVocab.UNCHECKED_VOCAB)); private static Map KNOWN_VOCAB_URIS = ImmutableMap.of(); private static Set DEFAULT_VOCAB_URIS = ImmutableSet.of(StructureVocab.URI); - + private final ValidationContext context; private final String path; private final Report report; @@ -85,8 +87,20 @@ else if (name.equals("body") || name.equals("par")) private void checkType(String type) { - VocabUtil.parsePropertyList(type, vocabs, context, + Set propList = VocabUtil.parsePropertyList(type, vocabs, context, EPUBLocation.create(path, parser.getLineNumber(), parser.getColumnNumber())); + + // Check unrecognized properties from the structure vocab + for (Property property : propList) + { + if (StructureVocab.URI.equals(property.getVocabURI())) try + { + property.toEnum(); + } catch (UnsupportedOperationException ex) + { + report.message(MessageId.OPF_088, parser.getLocation(), property.getName()); + } + } } private void processSrc(XMLElement e) diff --git a/src/test/resources/epub3/files/mediaoverlays-document/epubtype-unknown-error.smil b/src/test/resources/epub3/files/mediaoverlays-document/epubtype-unknown-usage.smil similarity index 100% rename from src/test/resources/epub3/files/mediaoverlays-document/epubtype-unknown-error.smil rename to src/test/resources/epub3/files/mediaoverlays-document/epubtype-unknown-usage.smil diff --git a/src/test/resources/epub3/mediaoverlays-smil-document.feature b/src/test/resources/epub3/mediaoverlays-smil-document.feature index 1ed70d3db..2784b13fc 100644 --- a/src/test/resources/epub3/mediaoverlays-smil-document.feature +++ b/src/test/resources/epub3/mediaoverlays-smil-document.feature @@ -93,8 +93,8 @@ Feature: EPUB 3 ▸ Media Overlays ▸ SMIL Document Checks And the message contains 'Undeclared prefix: "my"' And no other errors or warnings are reported - Scenario: Report an unknown epub:type property in the default vocabulary - When checking document 'epubtype-unknown-error.smil' - Then error OPF-027 is reported + Scenario: Allow unknown epub:type properties in the default vocabulary + Given the reporting level set to usage + When checking document 'epubtype-unknown-usage.smil' + Then usage OPF-088 is reported And no other errors or warnings are reported -