Skip to content

Commit

Permalink
feat: check that Media Overlays are only defined for XHTML and SVG co…
Browse files Browse the repository at this point in the history
…ntent documents

Add a schema rule to check the media type of items declaring
a `media-overlay` attribute

See #1176
  • Loading branch information
mattgarrish authored and rdeltour committed Dec 28, 2020
1 parent 413adc8 commit 5ae1aa9
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,12 @@
<let name="ref" value="./normalize-space(@media-overlay)"/>
<let name="item" value="//opf:manifest/opf:item[normalize-space(@id) = $ref]"/>
<let name="item-media-type" value="normalize-space($item/@media-type)"/>
<let name="media-type" value="normalize-space(@media-type)"/>
<assert test="$item-media-type = 'application/smil+xml'">media overlay items must be of
the "application/smil+xml" type (given type was "<value-of select="$item-media-type"
/>")</assert>
<assert test="$media-type='application/xhtml+xml' or $media-type='image/svg+xml'"
>The media-overlay attribute is only allowed on XHTML and SVG content documents.</assert>
</rule>
</pattern>

Expand Down Expand Up @@ -322,8 +325,8 @@
<rule context="opf:meta[normalize-space(@property)='media:playback-active-class']">
<report test="@refines"> @refines must not be used with the media:playback-active-class property</report>
</rule>
</pattern>
</pattern>



<!-- EPUB 3.2 New Checks -->
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<package xmlns="http://www.idpf.org/2007/opf" version="3.0" unique-identifier="uid"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<metadata>
<dc:title>Title</dc:title>
<dc:language>en</dc:language>
<dc:identifier id="uid">NOID</dc:identifier>
<meta property="dcterms:modified">2019-01-01T12:00:00Z</meta>
<!-- Media Overlays Duration Properties -->
<meta property="media:duration">0:01:30.200</meta>
<meta refines="#mo001" property="media:duration">0:01:30.200</meta>
</metadata>
<manifest>
<item id="t001" href="contents.xhtml" properties="nav" media-type="application/xhtml+xml" media-overlay="mo001"/>
<item id="img001" href="cover.jpg" media-type="image/jpeg" media-overlay="mo001"/>
<item id="mo001" href="mediaoverlay_001.smil" media-type="application/smil+xml"/>
</manifest>
<spine>
<itemref idref="t001"/>
</spine>
</package>
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ Feature: EPUB 3 ▸ Media Overlays ▸ Package Document Checks
And the message contains 'must be of the "application/smil+xml" type'
And no other errors or warnings are reported

Scenario: Report use of the media-overlay attribute on non-EPUB Content Documents
When checking file 'mediaoverlays-non-contentdoc-error.opf'
Then error RSC-005 is reported
And the message contains 'media-overlay attribute is only allowed'
And no other errors or warnings are reported

## 3.5.2 Package Metadata

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



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

0 comments on commit 5ae1aa9

Please sign in to comment.