Skip to content

Commit 177af8f

Browse files
committed
fix: allow empty xml:lang attributes in Package Documents
An empty `xml:lang` attribute can explicitly indicate that the content does not inherit the context language. Fixes #777
1 parent 6fa3312 commit 177af8f

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,5 +128,5 @@
128128
opf.href.attr = attribute href { datatype.URI }
129129
opf.id.attr = attribute id { datatype.ID }
130130
opf.i18n.attrs = opf.xml.lang.attr? & opf.dir.attr?
131-
opf.xml.lang.attr = attribute xml:lang { datatype.languagecode }
131+
opf.xml.lang.attr = attribute xml:lang { "" | datatype.languagecode }
132132
opf.dir.attr = attribute dir { 'ltr' | 'rtl' }
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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 xml:lang="">Jane Doe</dc:creator>
10+
</metadata>
11+
<manifest>
12+
<item id="t001" href="contents.xhtml" properties="nav" media-type="application/xhtml+xml"/>
13+
</manifest>
14+
<spine>
15+
<itemref idref="t001"/>
16+
</spine>
17+
</package>

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ Feature: EPUB 3 ▸ Packages ▸ Package Document Checks
3030
Then fatal error RSC-016 is reported (parsing error)
3131
And error RSC-005 is reported (schema error)
3232
And no other errors or warnings are reported
33-
34-
33+
34+
3535
# 3.4 Pacakge Document Definition
3636

3737
## 3.4.1 The package element
@@ -86,6 +86,10 @@ Feature: EPUB 3 ▸ Packages ▸ Package Document Checks
8686
When checking file 'id-duplicate-with-spaces-error.opf'
8787
Then error RSC-005 is reported 2 times (once for each ID)
8888
And no other errors or warnings are reported
89+
90+
Scenario: the `xml:lang` attribute can be empty
91+
When checking file 'lang-empty-valid.opf'
92+
Then no other errors or warnings are reported
8993

9094
## 3.4.3 Metadata
9195
### 3.4.3 The metadata element

0 commit comments

Comments
 (0)