Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix #777] Allow xml:lang="" by replacing datatype.languagecode by datatype.languagecode | string "". #778

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ div {

datatype.languagecode = datatype.BCP47
# http://www.w3.org/TR/xmlschema11-2/#language
datatype.BCP47 = xsd:language { pattern = "[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*" }
datatype.BCP47 = xsd:language
# http://www.w3.org/TR/xmlschema11-2/#ID
datatype.ID.xsd = xsd:ID
# http://www.w3.org/TR/xmlschema11-2/#NCName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@



html5.lang.attr = attribute lang { datatype.languagecode }
html5.xml.lang.attr = attribute xml:lang { datatype.languagecode }
html5.lang.attr = attribute lang { datatype.languagecode | string "" }
html5.xml.lang.attr = attribute xml:lang { datatype.languagecode | string "" }
html5.dir.attr = attribute dir { 'ltr' | 'rtl' | 'auto' }
html5.id.attr = attribute id { datatype.html5.token }
html5.title.attr = attribute title { string }
Expand All @@ -19,7 +19,7 @@
html5.xml.space.attr = attribute xml:space { 'preserve' | 'default' }

html5.href.attr = attribute href { datatype.html5.URL.spaces }
html5.hreflang.attr = attribute hreflang { datatype.languagecode }
html5.hreflang.attr = attribute hreflang { datatype.languagecode | string ""}
html5.target.attr = attribute target { datatype.html5.browsing.context.name.or.keyword }
html5.rel.attr = attribute rel { datatype.html5.space.separated.tokens }
html5.media.attr = attribute media { datatype.html5.media.query }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
& html5.track.srclang.attr? & html5.track.label.attr?

html5.track.kind.attr = attribute kind { 'subtitles' | 'captions' | 'descriptions' | 'chapters' | 'metadata' }
html5.track.srclang.attr = attribute srclang { datatype.languagecode }
html5.track.srclang.attr = attribute srclang { datatype.languagecode | string "" }
html5.track.label.attr = attribute label { datatype.string }
html5.track.default.attr = attribute default { 'default' | '' }

Expand Down
7 changes: 7 additions & 0 deletions src/test/java/com/adobe/epubcheck/ops/OPSCheckerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -928,4 +928,11 @@ public void testValidateXHTMLEmptyClass_EPUB2_Valid()
EPUBVersion.VERSION_2);
}

@Test
public void testValidateEmptyLangAttribute_EPUB3_Valid()
{
testValidateDocument("xhtml/valid/issue777-empty-lang.xhtml", "application/xhtml+xml",
EPUBVersion.VERSION_3);
}

}
11 changes: 11 additions & 0 deletions src/test/resources/30/single/xhtml/valid/issue777-empty-lang.xhtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Allow empty lang attribute</title>
</head>
<body>
<p lang="" xml:lang="">This para has an empty lang attribute which was invalid prior to v4.1</p>
<p>Details: https://github.com/IDPF/epubcheck/issues/777</p>
</body>
</html>