Skip to content

Commit 6c68c61

Browse files
authored
feat: allow multiple roles for creator, contributor, and publisher (#1258)
In EPUB 3.2, the 'role' property was only allowed to refine 'contributor' or 'creator' properties, and only once per property. A new check was introduced in EPUBCheck v4.2.5, and some users reported that it cause issues with existing EPUB catalogs. EPUB 3.3 will relax this by allowing authors to attach several roles to creators, contributors, and publishers. This commit proactively implements the relaxed EPUB 3.3 rules. Fixes #1230
1 parent 1201623 commit 6c68c61

File tree

4 files changed

+42
-13
lines changed

4 files changed

+42
-13
lines changed

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,8 @@
128128

129129
<pattern id="opf.meta.role">
130130
<rule context="opf:meta[normalize-space(@property)='role']">
131-
<assert test="exists(../(dc:creator|dc:contributor)[concat('#',normalize-space(@id)) = normalize-space(current()/@refines)])"
132-
>Property "role" must refine a "creator" or "contributor" property.</assert>
133-
<report test="exists(preceding-sibling::opf:meta[normalize-space(@property) = normalize-space(current()/@property)][normalize-space(@refines) = normalize-space(current()/@refines)])"
134-
>Property "role" cannot be declared more than once to refine a single "creator" or "contributor" property.</report>
131+
<assert test="exists(../(dc:creator|dc:contributor|dc:publisher)[concat('#',normalize-space(@id)) = normalize-space(current()/@refines)])"
132+
>Property "role" must refine a "creator", "contributor", or "publisher" property.</assert>
135133
</rule>
136134
</pattern>
137135

src/test/resources/epub3/files/package-document/metadata-meta-role-cardinality-error.opf renamed to src/test/resources/epub3/files/package-document/metadata-meta-role-refines-disallowed-error.opf

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,11 @@
22
<package xmlns="http://www.idpf.org/2007/opf" version="3.0" unique-identifier="uid"
33
xmlns:dc="http://purl.org/dc/elements/1.1/">
44
<metadata>
5-
<dc:title>Title</dc:title>
5+
<dc:title id="title">Title</dc:title>
66
<dc:language>en</dc:language>
77
<dc:identifier id="uid">NOID</dc:identifier>
88
<meta property="dcterms:modified">2019-01-01T12:00:00Z</meta>
9-
<dc:creator id="creator1">Jane Doe</dc:creator>
10-
<dc:creator id="creator2">John Doe</dc:creator>
11-
<meta property="role" refines="#creator1">aut</meta>
12-
<meta property="role" refines="#creator1">edt</meta>
13-
<meta property="role" refines="#creator2">aut</meta>
9+
<meta property="role" refines="#title">title</meta>
1410
</metadata>
1511
<manifest>
1612
<item id="t001" href="contents.xhtml" properties="nav" media-type="application/xhtml+xml"/>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
<dc:creator id="creator1">Jane Doe</dc:creator>
10+
<dc:creator id="creator2">John Doe</dc:creator>
11+
<dc:contributor id="contributor">Claudia Contributor</dc:contributor>
12+
<dc:publisher id="publisher">Paula Publisher</dc:publisher>
13+
<!-- Multiple roles for a single creator -->
14+
<meta property="role" refines="#creator1">aut</meta>
15+
<meta property="role" refines="#creator1">ill</meta>
16+
<!--Role for another creator-->
17+
<meta property="role" refines="#creator2">aut</meta>
18+
<!-- Multiple roles for a contributor -->
19+
<meta property="role" refines="#contributor">ill</meta>
20+
<meta property="role" refines="#contributor">bkd</meta>
21+
<!-- Multiple roles for a publisher -->
22+
<meta property="role" refines="#publisher">pbl</meta>
23+
<meta property="role" refines="#publisher">pbd</meta>
24+
</metadata>
25+
<manifest>
26+
<item id="t001" href="contents.xhtml" properties="nav" media-type="application/xhtml+xml"/>
27+
</manifest>
28+
<spine>
29+
<itemref idref="t001"/>
30+
</spine>
31+
</package>

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -730,10 +730,14 @@ Feature: EPUB 3 ▸ Packages ▸ Package Document Checks
730730
And the message contains "the meta-auth property is deprecated"
731731
And no other errors or warnings are reported
732732

733-
Scenario: 'role' metadata cannot be defined more than once to refine the same expression
734-
When checking file 'metadata-meta-role-cardinality-error.opf'
733+
Scenario: 'role' metadata can be used once or more to refine a creator, contributor, or publisher
734+
When checking file 'metadata-meta-role-valid.opf'
735+
Then no errors or warnings are reported
736+
737+
Scenario: 'role' metadata cannot be used to refine properties other than creator, contributor, or publisher
738+
When checking file 'metadata-meta-role-refines-disallowed-error.opf'
735739
Then error RSC-005 is reported
736-
And the message contains '"role" cannot be declared more than once'
740+
And the message contains '"role" must refine a "creator", "contributor", or "publisher" property'
737741
And no other errors or warnings are reported
738742

739743
Scenario: 'source-of' metadata can be used to refine the pagination source

0 commit comments

Comments
 (0)