Skip to content

Commit

Permalink
Allow xml:lang="" by replacing datatype.languagecode by datatype.lang…
Browse files Browse the repository at this point in the history
…uagecode | string "". (#778)

* Allow xml:lang="" by replacing datatype.languagecode by datatype.languagecode | string "".

* Add test for schema changes for empty lang attribute

fixes #777
  • Loading branch information
murata2makoto authored and tofi86 committed Jul 10, 2017
1 parent b66fd87 commit 392c2f6
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 5 deletions.
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
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
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
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
@@ -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>

0 comments on commit 392c2f6

Please sign in to comment.