Skip to content

Commit

Permalink
feat: report empty title elements in XHTML Content Documents (#1135)
Browse files Browse the repository at this point in the history
Empty or whitespace-only `title` elements are disallowed in HTML:
  https://html.spec.whatwg.org/#the-title-element

Nu HTML Checker checks this with Java Code, so it’s not exposed in
EPUBCheck (which only uses the Checkr’s schemas).
This change re-implements the check in Schematron.

Fixes #1093
  • Loading branch information
rdeltour committed May 1, 2020
1 parent ee06724 commit f115730
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@
</rule>
</pattern>

<pattern id="title.non-empty">
<rule context="h:title">
<assert test="normalize-space(.)"
>Element "title" must not be empty.</assert>
</rule>
</pattern>

<pattern id="epub.switch.deprecated">
<rule context="epub:switch">
<report test="true()"
Expand Down
8 changes: 8 additions & 0 deletions src/test/java/com/adobe/epubcheck/ops/OPSCheckerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1392,4 +1392,12 @@ public void testIdRefNotFound()
EPUBVersion.VERSION_3);
}

@Test
public void testTitleEmpty()
{
Collections.addAll(expectedErrors, MessageId.RSC_005);
testValidateDocument("xhtml/invalid/title-empty.xhtml", "application/xhtml+xml",
EPUBVersion.VERSION_3);
}

}
2 changes: 1 addition & 1 deletion src/test/resources/30/single/xhtml/invalid/issue153.xhtml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<title>Test</title>
</head>
<body>
<math xmlns="http://www.w3.org/1998/Math/MathML">
Expand Down
10 changes: 10 additions & 0 deletions src/test/resources/30/single/xhtml/invalid/title-empty.xhtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<title></title>
<meta charset="UTF-8"/>
</head>
<body>
<h1>Test</h1>
</body>
</html>

0 comments on commit f115730

Please sign in to comment.