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

match epub:type checking in overlays documents to content documents #1171

Merged
merged 2 commits into from
Sep 1, 2020
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
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