Skip to content

Commit 794b7ce

Browse files
mattgarrishrdeltour
authored andcommitted
feat: verify 'media:duration' property use valid SMIL clock values
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
1 parent f8a2517 commit 794b7ce

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,14 @@
274274

275275
<!-- Media overlay checks -->
276276

277+
<pattern id="opf.duration.metadata.item">
278+
<rule context="opf:meta[normalize-space(@property)='media:duration']">
279+
<assert
280+
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*)))$')"
281+
>The value of the media:duration property must be a valid SMIL3 clock value</assert>
282+
</rule>
283+
</pattern>
284+
277285
<pattern id="opf.media.overlay">
278286
<rule context="opf:item[@media-overlay]">
279287
<let name="ref" value="./normalize-space(@media-overlay)"/>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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:9999:12.121</meta>
12+
<meta refines="#mo002" property="media:duration">45mon</meta>
13+
</metadata>
14+
<manifest>
15+
<item id="t001" href="contents_001.xhtml" properties="nav" media-type="application/xhtml+xml"/>
16+
<item id="mo001" href="mediaoverlay_001.smil" media-type="application/smil+xml"/>
17+
<item id="t002" href="contents_002.xhtml" media-type="application/xhtml+xml"/>
18+
<item id="mo002" href="mediaoverlay_002.smil" media-type="application/smil+xml"/>
19+
</manifest>
20+
<spine>
21+
<itemref idref="t001"/>
22+
</spine>
23+
</package>

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,12 @@ Feature: EPUB 3 ▸ Media Overlays ▸ Package Document Checks
5959
Then error RSC-005 is reported
6060
And the message contains "must not be used with the media:playback-active-class property"
6161
And no other errors or warnings are reported
62+
63+
Scenario: Report 'media:duration' properties with non-clock values
64+
When checking file 'mediaoverlays-duration-clock-values-error.opf'
65+
Then the following errors are reported
66+
| RSC-005 | must be a valid SMIL3 clock value |
67+
| RSC-005 | must be a valid SMIL3 clock value |
68+
| RSC-005 | must be a valid SMIL3 clock value |
69+
And no other errors or warnings are reported
70+

0 commit comments

Comments
 (0)