Skip to content

Commit f115730

Browse files
authored
feat: report empty title elements in XHTML Content Documents (#1135)
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
1 parent ee06724 commit f115730

4 files changed

Lines changed: 26 additions & 1 deletion

File tree

src/main/resources/com/adobe/epubcheck/schema/30/epub-xhtml-30.sch

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@
2828
</rule>
2929
</pattern>
3030

31+
<pattern id="title.non-empty">
32+
<rule context="h:title">
33+
<assert test="normalize-space(.)"
34+
>Element "title" must not be empty.</assert>
35+
</rule>
36+
</pattern>
37+
3138
<pattern id="epub.switch.deprecated">
3239
<rule context="epub:switch">
3340
<report test="true()"

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,4 +1392,12 @@ public void testIdRefNotFound()
13921392
EPUBVersion.VERSION_3);
13931393
}
13941394

1395+
@Test
1396+
public void testTitleEmpty()
1397+
{
1398+
Collections.addAll(expectedErrors, MessageId.RSC_005);
1399+
testValidateDocument("xhtml/invalid/title-empty.xhtml", "application/xhtml+xml",
1400+
EPUBVersion.VERSION_3);
1401+
}
1402+
13951403
}

src/test/resources/30/single/xhtml/invalid/issue153.xhtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<html xmlns="http://www.w3.org/1999/xhtml">
22
<head>
3-
<title></title>
3+
<title>Test</title>
44
</head>
55
<body>
66
<math xmlns="http://www.w3.org/1998/Math/MathML">
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!DOCTYPE html>
2+
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
3+
<head>
4+
<title></title>
5+
<meta charset="UTF-8"/>
6+
</head>
7+
<body>
8+
<h1>Test</h1>
9+
</body>
10+
</html>

0 commit comments

Comments
 (0)