Skip to content

Commit

Permalink
feat: add new 'voicing' link relationship
Browse files Browse the repository at this point in the history
- add `VOICING` to the built-in link rel vocab
- add schematron rules for `voicing` links
- add related tests

See w3c/epub-specs#1248
  • Loading branch information
rdeltour committed Apr 22, 2019
1 parent 123c69f commit 97e9f1c
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/main/java/com/adobe/epubcheck/vocab/PackageVocabs.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public static enum LINKREL_PROPERTIES implements PropertyStatus
MODS_RECORD(DEPRECATED),
ONIX_RECORD(DEPRECATED),
RECORD,
VOICING,
XML_SIGNATURE(DEPRECATED),
XMP_RECORD(DEPRECATED);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@
have a 'refines' attribute).</assert>
</rule>
</pattern>

<pattern id="opf.link.voicing">
<rule context="opf:link[tokenize(@rel,'\s+')='voicing']">
<assert test="starts-with(normalize-space(@media-type),'audio/')">'voicing' links must have a 'media-type' attribute identifying an audio MIME type.</assert>
<assert test="exists(@refines)">'voicing' links must have a 'refines' attribute.</assert>
</rule>
</pattern>

<pattern id="opf.meta.belongs-to-collection">
<rule context="opf:meta[normalize-space(@property)='belongs-to-collection']">
Expand Down
31 changes: 31 additions & 0 deletions src/test/java/com/adobe/epubcheck/opf/OPFCheckerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,37 @@ public void testLinkRelRecordWithRefines()
expectedErrors.add(MessageId.RSC_005);
testValidateDocument("invalid/link-rel-record-refines.opf", EPUBVersion.VERSION_3);
}

@Test
public void testLinkRelVoicing()
{
// tests that the 'voicing' link rel keyword is accepted
testValidateDocument("valid/link-rel-voicing.opf", EPUBVersion.VERSION_3);
}

@Test
public void testLinkRelVoicingWithNoRefinesAttribute()
{
// tests that 'voicing' links must have a 'refines' attribute
expectedErrors.add(MessageId.RSC_005);
testValidateDocument("invalid/link-rel-voicing-no-refines.opf", EPUBVersion.VERSION_3);
}

@Test
public void testLinkRelVoicingWithNoMediaType()
{
// tests that 'voicing' links must have a 'media-type' attribute
expectedErrors.add(MessageId.RSC_005);
testValidateDocument("invalid/link-rel-voicing-no-type.opf", EPUBVersion.VERSION_3);
}

@Test
public void testLinkRelVoicingWithMediaTypeNotAudio()
{
// tests that 'voicing' links must refer to resources with an audio mime type
expectedErrors.add(MessageId.RSC_005);
testValidateDocument("invalid/link-rel-voicing-not-audio.opf", EPUBVersion.VERSION_3);
}

@Test
public void testLink_ResourceInManifest()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?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:identifier id="uid">xxx</dc:identifier>
<dc:title id="title">Title</dc:title>
<dc:language>en</dc:language>
<meta property="dcterms:modified">2019-01-01T12:00:00Z</meta>
<link rel="voicing" href="title.mp3" media-type="audio/mpeg"/>
</metadata>
<manifest>
<item id="t001" href="contents.xhtml" properties="nav" media-type="application/xhtml+xml"/>
</manifest>
<spine>
<itemref idref="t001"/>
</spine>
</package>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?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:identifier id="uid">xxx</dc:identifier>
<dc:title id="title">Title</dc:title>
<dc:language>en</dc:language>
<meta property="dcterms:modified">2019-01-01T12:00:00Z</meta>
<link rel="voicing" refines="#title" href="title.mp3"/>
</metadata>
<manifest>
<item id="t001" href="contents.xhtml" properties="nav" media-type="application/xhtml+xml"/>
</manifest>
<spine>
<itemref idref="t001"/>
</spine>
</package>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?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:identifier id="uid">xxx</dc:identifier>
<dc:title id="title">Title</dc:title>
<dc:language>en</dc:language>
<meta property="dcterms:modified">2019-01-01T12:00:00Z</meta>
<link rel="voicing" refines="title" href="title.mp3" media-type="application/vnd.foo"/>
</metadata>
<manifest>
<item id="t001" href="contents.xhtml" properties="nav" media-type="application/xhtml+xml"/>
</manifest>
<spine>
<itemref idref="t001"/>
</spine>
</package>
17 changes: 17 additions & 0 deletions src/test/resources/30/single/opf/valid/link-rel-voicing.opf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?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:identifier id="uid">xxx</dc:identifier>
<dc:title id="title">Title</dc:title>
<dc:language>en</dc:language>
<meta property="dcterms:modified">2019-01-01T12:00:00Z</meta>
<link rel="voicing" refines="#title" href="title.mp3" media-type="audio/mpeg"/>
</metadata>
<manifest>
<item id="t001" href="contents.xhtml" properties="nav" media-type="application/xhtml+xml"/>
</manifest>
<spine>
<itemref idref="t001"/>
</spine>
</package>

0 comments on commit 97e9f1c

Please sign in to comment.