Skip to content

Commit f8a2517

Browse files
authored
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).
1 parent 05a6a20 commit f8a2517

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

src/main/java/com/adobe/epubcheck/overlay/OverlayHandler.java

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
import com.adobe.epubcheck.util.EpubConstants;
1313
import com.adobe.epubcheck.util.HandlerUtil;
1414
import com.adobe.epubcheck.util.PathUtil;
15+
import com.adobe.epubcheck.vocab.Property;
16+
import com.adobe.epubcheck.vocab.AggregateVocab;
1517
import com.adobe.epubcheck.vocab.StructureVocab;
1618
import com.adobe.epubcheck.vocab.Vocab;
1719
import com.adobe.epubcheck.vocab.VocabUtil;
@@ -25,10 +27,10 @@ public class OverlayHandler implements XMLHandler
2527
{
2628

2729
private static Map<String, Vocab> RESERVED_VOCABS = ImmutableMap.<String, Vocab> of("",
28-
StructureVocab.VOCAB);
30+
AggregateVocab.of(StructureVocab.VOCAB, StructureVocab.UNCHECKED_VOCAB));
2931
private static Map<String, Vocab> KNOWN_VOCAB_URIS = ImmutableMap.of();
3032
private static Set<String> DEFAULT_VOCAB_URIS = ImmutableSet.of(StructureVocab.URI);
31-
33+
3234
private final ValidationContext context;
3335
private final String path;
3436
private final Report report;
@@ -85,8 +87,20 @@ else if (name.equals("body") || name.equals("par"))
8587

8688
private void checkType(String type)
8789
{
88-
VocabUtil.parsePropertyList(type, vocabs, context,
90+
Set<Property> propList = VocabUtil.parsePropertyList(type, vocabs, context,
8991
EPUBLocation.create(path, parser.getLineNumber(), parser.getColumnNumber()));
92+
93+
// Check unrecognized properties from the structure vocab
94+
for (Property property : propList)
95+
{
96+
if (StructureVocab.URI.equals(property.getVocabURI())) try
97+
{
98+
property.toEnum();
99+
} catch (UnsupportedOperationException ex)
100+
{
101+
report.message(MessageId.OPF_088, parser.getLocation(), property.getName());
102+
}
103+
}
90104
}
91105

92106
private void processSrc(XMLElement e)

src/test/resources/epub3/mediaoverlays-smil-document.feature

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ Feature: EPUB 3 ▸ Media Overlays ▸ SMIL Document Checks
9393
And the message contains 'Undeclared prefix: "my"'
9494
And no other errors or warnings are reported
9595

96-
Scenario: Report an unknown epub:type property in the default vocabulary
97-
When checking document 'epubtype-unknown-error.smil'
98-
Then error OPF-027 is reported
96+
Scenario: Allow unknown epub:type properties in the default vocabulary
97+
Given the reporting level set to usage
98+
When checking document 'epubtype-unknown-usage.smil'
99+
Then usage OPF-088 is reported
99100
And no other errors or warnings are reported
100-

0 commit comments

Comments
 (0)