Skip to content

Commit

Permalink
feat: report unknown 'epub:type' values in overlays as USAGE only (#1171
Browse files Browse the repository at this point in the history
)

Matches `epub:type` checking in Media Overlays documents to Content Documents (`USAGE` message for unknown values from structure vocab).
  • Loading branch information
mattgarrish authored Sep 1, 2020
1 parent 05a6a20 commit f8a2517
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
20 changes: 17 additions & 3 deletions src/main/java/com/adobe/epubcheck/overlay/OverlayHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -25,10 +27,10 @@ public class OverlayHandler implements XMLHandler
{

private static Map<String, Vocab> RESERVED_VOCABS = ImmutableMap.<String, Vocab> of("",
StructureVocab.VOCAB);
AggregateVocab.of(StructureVocab.VOCAB, StructureVocab.UNCHECKED_VOCAB));
private static Map<String, Vocab> KNOWN_VOCAB_URIS = ImmutableMap.of();
private static Set<String> DEFAULT_VOCAB_URIS = ImmutableSet.of(StructureVocab.URI);

private final ValidationContext context;
private final String path;
private final Report report;
Expand Down Expand Up @@ -85,8 +87,20 @@ else if (name.equals("body") || name.equals("par"))

private void checkType(String type)
{
VocabUtil.parsePropertyList(type, vocabs, context,
Set<Property> 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)
Expand Down
8 changes: 4 additions & 4 deletions src/test/resources/epub3/mediaoverlays-smil-document.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit f8a2517

Please sign in to comment.