Skip to content

Commit 392c2f6

Browse files
murata2makototofi86
authored andcommitted
Allow xml:lang="" by replacing datatype.languagecode by datatype.languagecode | string "". (#778)
* Allow xml:lang="" by replacing datatype.languagecode by datatype.languagecode | string "". * Add test for schema changes for empty lang attribute fixes #777
1 parent b66fd87 commit 392c2f6

File tree

5 files changed

+23
-5
lines changed

5 files changed

+23
-5
lines changed

src/main/resources/com/adobe/epubcheck/schema/30/mod/datatypes.rnc

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ div {
66

77
datatype.languagecode = datatype.BCP47
88
# http://www.w3.org/TR/xmlschema11-2/#language
9-
datatype.BCP47 = xsd:language { pattern = "[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*" }
9+
datatype.BCP47 = xsd:language
1010
# http://www.w3.org/TR/xmlschema11-2/#ID
1111
datatype.ID.xsd = xsd:ID
1212
# http://www.w3.org/TR/xmlschema11-2/#NCName

src/main/resources/com/adobe/epubcheck/schema/30/mod/html5/html5-attrib-30.rnc

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010

1111

12-
html5.lang.attr = attribute lang { datatype.languagecode }
13-
html5.xml.lang.attr = attribute xml:lang { datatype.languagecode }
12+
html5.lang.attr = attribute lang { datatype.languagecode | string "" }
13+
html5.xml.lang.attr = attribute xml:lang { datatype.languagecode | string "" }
1414
html5.dir.attr = attribute dir { 'ltr' | 'rtl' | 'auto' }
1515
html5.id.attr = attribute id { datatype.html5.token }
1616
html5.title.attr = attribute title { string }
@@ -19,7 +19,7 @@
1919
html5.xml.space.attr = attribute xml:space { 'preserve' | 'default' }
2020

2121
html5.href.attr = attribute href { datatype.html5.URL.spaces }
22-
html5.hreflang.attr = attribute hreflang { datatype.languagecode }
22+
html5.hreflang.attr = attribute hreflang { datatype.languagecode | string ""}
2323
html5.target.attr = attribute target { datatype.html5.browsing.context.name.or.keyword }
2424
html5.rel.attr = attribute rel { datatype.html5.space.separated.tokens }
2525
html5.media.attr = attribute media { datatype.html5.media.query }

src/main/resources/com/adobe/epubcheck/schema/30/mod/html5/html5-embed-30.rnc

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
& html5.track.srclang.attr? & html5.track.label.attr?
3838

3939
html5.track.kind.attr = attribute kind { 'subtitles' | 'captions' | 'descriptions' | 'chapters' | 'metadata' }
40-
html5.track.srclang.attr = attribute srclang { datatype.languagecode }
40+
html5.track.srclang.attr = attribute srclang { datatype.languagecode | string "" }
4141
html5.track.label.attr = attribute label { datatype.string }
4242
html5.track.default.attr = attribute default { 'default' | '' }
4343

src/test/java/com/adobe/epubcheck/ops/OPSCheckerTest.java

+7
Original file line numberDiff line numberDiff line change
@@ -928,4 +928,11 @@ public void testValidateXHTMLEmptyClass_EPUB2_Valid()
928928
EPUBVersion.VERSION_2);
929929
}
930930

931+
@Test
932+
public void testValidateEmptyLangAttribute_EPUB3_Valid()
933+
{
934+
testValidateDocument("xhtml/valid/issue777-empty-lang.xhtml", "application/xhtml+xml",
935+
EPUBVersion.VERSION_3);
936+
}
937+
931938
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE html>
3+
<html xmlns="http://www.w3.org/1999/xhtml">
4+
<head>
5+
<title>Allow empty lang attribute</title>
6+
</head>
7+
<body>
8+
<p lang="" xml:lang="">This para has an empty lang attribute which was invalid prior to v4.1</p>
9+
<p>Details: https://github.com/IDPF/epubcheck/issues/777</p>
10+
</body>
11+
</html>

0 commit comments

Comments
 (0)