Skip to content

Commit 5ae1aa9

Browse files
mattgarrishrdeltour
authored andcommitted
feat: check that Media Overlays are only defined for XHTML and SVG content documents
Add a schema rule to check the media type of items declaring a `media-overlay` attribute See #1176
1 parent 413adc8 commit 5ae1aa9

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed

src/main/resources/com/adobe/epubcheck/schema/30/package-30.sch

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,12 @@
287287
<let name="ref" value="./normalize-space(@media-overlay)"/>
288288
<let name="item" value="//opf:manifest/opf:item[normalize-space(@id) = $ref]"/>
289289
<let name="item-media-type" value="normalize-space($item/@media-type)"/>
290+
<let name="media-type" value="normalize-space(@media-type)"/>
290291
<assert test="$item-media-type = 'application/smil+xml'">media overlay items must be of
291292
the "application/smil+xml" type (given type was "<value-of select="$item-media-type"
292293
/>")</assert>
294+
<assert test="$media-type='application/xhtml+xml' or $media-type='image/svg+xml'"
295+
>The media-overlay attribute is only allowed on XHTML and SVG content documents.</assert>
293296
</rule>
294297
</pattern>
295298

@@ -322,8 +325,8 @@
322325
<rule context="opf:meta[normalize-space(@property)='media:playback-active-class']">
323326
<report test="@refines"> @refines must not be used with the media:playback-active-class property</report>
324327
</rule>
325-
</pattern>
326-
328+
</pattern>
329+
327330

328331

329332
<!-- EPUB 3.2 New Checks -->
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<package xmlns="http://www.idpf.org/2007/opf" version="3.0" unique-identifier="uid"
3+
xmlns:dc="http://purl.org/dc/elements/1.1/">
4+
<metadata>
5+
<dc:title>Title</dc:title>
6+
<dc:language>en</dc:language>
7+
<dc:identifier id="uid">NOID</dc:identifier>
8+
<meta property="dcterms:modified">2019-01-01T12:00:00Z</meta>
9+
<!-- Media Overlays Duration Properties -->
10+
<meta property="media:duration">0:01:30.200</meta>
11+
<meta refines="#mo001" property="media:duration">0:01:30.200</meta>
12+
</metadata>
13+
<manifest>
14+
<item id="t001" href="contents.xhtml" properties="nav" media-type="application/xhtml+xml" media-overlay="mo001"/>
15+
<item id="img001" href="cover.jpg" media-type="image/jpeg" media-overlay="mo001"/>
16+
<item id="mo001" href="mediaoverlay_001.smil" media-type="application/smil+xml"/>
17+
</manifest>
18+
<spine>
19+
<itemref idref="t001"/>
20+
</spine>
21+
</package>

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ Feature: EPUB 3 ▸ Media Overlays ▸ Package Document Checks
2323
And the message contains 'must be of the "application/smil+xml" type'
2424
And no other errors or warnings are reported
2525

26+
Scenario: Report use of the media-overlay attribute on non-EPUB Content Documents
27+
When checking file 'mediaoverlays-non-contentdoc-error.opf'
28+
Then error RSC-005 is reported
29+
And the message contains 'media-overlay attribute is only allowed'
30+
And no other errors or warnings are reported
31+
2632
## 3.5.2 Package Metadata
2733

2834
Scenario: the entire publication duration must be defined
@@ -36,6 +42,8 @@ Feature: EPUB 3 ▸ Media Overlays ▸ Package Document Checks
3642
Then error RSC-005 is reported
3743
And the message contains "item media:duration meta element not set"
3844
And no other errors or warnings are reported
45+
46+
3947

4048
# C. Media Overlays Metadata Vocabulary
4149
# see https://www.w3.org/publishing/epub32/epub-mediaoverlays.html#app-overlays-vocab

0 commit comments

Comments
 (0)