Skip to content

Commit

Permalink
feat: verify 'media:duration' property use valid SMIL clock values
Browse files Browse the repository at this point in the history
Adds a schematron test to check that `media:duration` values are valid
SMIL clock values (based on the regex used in the Media Overlays schema
to verify `clipBegin` and `clipEnd` attribute values)

Closes #1174
  • Loading branch information
mattgarrish authored and rdeltour committed Sep 1, 2020
1 parent f8a2517 commit 794b7ce
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,14 @@

<!-- Media overlay checks -->

<pattern id="opf.duration.metadata.item">
<rule context="opf:meta[normalize-space(@property)='media:duration']">
<assert
test="matches(normalize-space(),'^(([0-9]+:[0-5][0-9]:[0-5][0-9](\.[0-9]+)?)|((\s*)[0-5][0-9]:[0-5][0-9](\.[0-9]+)?(\s*))|((\s*)[0-9]+(\.[0-9]+)?(h|min|s|ms)?(\s*)))$')"
>The value of the media:duration property must be a valid SMIL3 clock value</assert>
</rule>
</pattern>

<pattern id="opf.media.overlay">
<rule context="opf:item[@media-overlay]">
<let name="ref" value="./normalize-space(@media-overlay)"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?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:9999:12.121</meta>
<meta refines="#mo002" property="media:duration">45mon</meta>
</metadata>
<manifest>
<item id="t001" href="contents_001.xhtml" properties="nav" media-type="application/xhtml+xml"/>
<item id="mo001" href="mediaoverlay_001.smil" media-type="application/smil+xml"/>
<item id="t002" href="contents_002.xhtml" media-type="application/xhtml+xml"/>
<item id="mo002" href="mediaoverlay_002.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 @@ -59,3 +59,12 @@ Feature: EPUB 3 ▸ Media Overlays ▸ Package Document Checks
Then error RSC-005 is reported
And the message contains "must not be used with the media:playback-active-class property"
And no other errors or warnings are reported

Scenario: Report 'media:duration' properties with non-clock values
When checking file 'mediaoverlays-duration-clock-values-error.opf'
Then the following errors are reported
| RSC-005 | must be a valid SMIL3 clock value |
| RSC-005 | must be a valid SMIL3 clock value |
| RSC-005 | must be a valid SMIL3 clock value |
And no other errors or warnings are reported

0 comments on commit 794b7ce

Please sign in to comment.