GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: check that non-linear content is reachable · w3c/epubcheck@f20993e

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src
    • main
      • java/com/adobe/epubcheck
        • messages
          • DefaultSeverities.java
          • MessageId.java
        • opf
          • OPFChecker30.java
      • resources/com/adobe/epubcheck/messages
        • MessageBundle.properties
    • test/resources
      • epub-edupub
        • edupub-publication.feature
        • files/epub/edupub-non-linear-valid/EPUB
          • nav.xhtml
          • package.opf
      • epub-region-nav/files/epub/data-nav-in-spine-warning/EPUB
        • nav.xhtml
      • epub3
        • 05-package-document
          • files
            • spine-empty-error.opf
            • spine-missing-error.opf
            • spine-no-linear-itemref-error.opf
            • spine-nonlinear-not-reachable-error
              • EPUB
                • content_001.xhtml
                • content_002.xhtml
                • nav.xhtml
                • package.opf
              • META-INF
                • container.xml
              • mimetype
            • spine-nonlinear-reachable-via-hyperlink-valid
              • EPUB
                • content_001.xhtml
                • content_002.xhtml
                • nav.xhtml
                • package.opf
              • META-INF
                • container.xml
              • mimetype
            • spine-nonlinear-reachable-via-nav-valid
              • EPUB
                • content_001.xhtml
                • content_002.xhtml
                • nav.xhtml
                • package.opf
              • META-INF
                • container.xml
              • mimetype
            • spine-nonlinear-reachable-via-script-valid
              • EPUB
                • content_001.xhtml
                • content_002.xhtml
                • nav.xhtml
                • package.opf
              • META-INF
                • container.xml
              • mimetype
            • spine-not-listing-hyperlink-target-error
              • EPUB
                • content_001.xhtml
                • content_002.xhtml
                • nav.xhtml
                • package.opf
              • META-INF
                • container.xml
              • mimetype
            • spine-not-listing-navigation-document-target-error
              • EPUB
                • content_001.xhtml
                • content_002.xhtml
                • nav.xhtml
                • package.opf
              • META-INF
                • container.xml
              • mimetype
          • package-document.feature
        • 06-content-document
          • content-document-xhtml.feature
        • 08-layout/files
          • content-fxl-svg-no-viewbox-error/EPUB
            • package.opf
          • content-fxl-svg-no-viewbox-on-inner-svg-valid/EPUB
            • package.opf
          • content-fxl-svg-no-viewbox-width-height-percent-error/EPUB
            • package.opf
          • content-fxl-svg-no-viewbox-width-height-units-error/EPUB
            • package.opf
          • content-fxl-svg-valid/EPUB
            • package.opf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/main/java/com/adobe/epubcheck/messages/DefaultSeverities.java‎

Copy file name to clipboardExpand all lines: src/main/java/com/adobe/epubcheck/messages/DefaultSeverities.java
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,8 @@ private void initialize()
289289
severities.put(MessageId.OPF_093, Severity.ERROR);
290290
severities.put(MessageId.OPF_094, Severity.ERROR);
291291
severities.put(MessageId.OPF_095, Severity.ERROR);
292+
severities.put(MessageId.OPF_096, Severity.ERROR);
293+
severities.put(MessageId.OPF_096b, Severity.USAGE);
292294

293295
// PKG
294296
severities.put(MessageId.PKG_001, Severity.WARNING);
Collapse file

‎src/main/java/com/adobe/epubcheck/messages/MessageId.java‎

Copy file name to clipboardExpand all lines: src/main/java/com/adobe/epubcheck/messages/MessageId.java
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,8 @@ public enum MessageId implements Comparable<MessageId>
283283
OPF_093("OPF-093"),
284284
OPF_094("OPF-094"),
285285
OPF_095("OPF-095"),
286+
OPF_096("OPF-096"),
287+
OPF_096b("OPF-096b"),
286288

287289
// Messages relating to the entire package
288290
PKG_001("PKG-001"),
Collapse file

‎src/main/java/com/adobe/epubcheck/opf/OPFChecker30.java‎

Copy file name to clipboardExpand all lines: src/main/java/com/adobe/epubcheck/opf/OPFChecker30.java
+24-3Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
import java.util.Set;
2626

27+
import org.w3c.epubcheck.core.references.Reference;
2728
import org.w3c.epubcheck.util.url.URLFragment;
2829

2930
import com.adobe.epubcheck.api.EPUBLocation;
@@ -183,6 +184,26 @@ else if (!overlayTextChecker.isCorrectOverlay(docURL, mo))
183184
}
184185
}
185186
}
187+
188+
// check that non-linear content documents are reachable
189+
if (item.isInSpine() && !item.isLinear() && context.referenceRegistry.isPresent()
190+
// search the reference registry for any hyperlink pointing to this item
191+
&& !context.referenceRegistry.get().asList().stream()
192+
.anyMatch(ref -> ref.type == Reference.Type.HYPERLINK
193+
&& ref.targetResource.equals(item.getURL())))
194+
{
195+
// if content is scripted, references can be added by scripting
196+
// se we only report a usage
197+
if (context.featureReport.hasFeature(FeatureEnum.HAS_SCRIPTS))
198+
{
199+
report.message(MessageId.OPF_096b, item.getLocation(), item.getPath());
200+
}
201+
// else, report an error if no hyperlink were found
202+
else
203+
{
204+
report.message(MessageId.OPF_096, item.getLocation(), item.getPath());
205+
}
206+
}
186207
}
187208

188209
@Override
@@ -194,14 +215,15 @@ protected void checkSpineItem(OPFItem item, OPFHandler opfHandler)
194215
return;
195216
}
196217

197-
String mimeType = item.getMimeType();
198-
218+
// check properties
199219
if (item.getProperties()
200220
.contains(PackageVocabs.ITEM_VOCAB.get(PackageVocabs.ITEM_PROPERTIES.DATA_NAV)))
201221
{
202222
report.message(MessageId.OPF_077, item.getLocation());
203223
}
204224

225+
// check that spine items have content document fallback
226+
String mimeType = item.getMimeType();
205227
if (!isBlessedItemType(mimeType, version))
206228
{
207229
if (!item.hasFallback())
@@ -213,7 +235,6 @@ else if (!item.hasContentDocumentFallback())
213235
report.message(MessageId.OPF_044, item.getLocation(), mimeType);
214236
}
215237
}
216-
217238
}
218239

219240
private void checkCollections()
Collapse file

‎src/main/resources/com/adobe/epubcheck/messages/MessageBundle.properties‎

Copy file name to clipboardExpand all lines: src/main/resources/com/adobe/epubcheck/messages/MessageBundle.properties
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,9 @@ OPF_091=The item href URL must not have a fragment identifier.
210210
OPF_092=Language tag "%1$s" is not well-formed: %2$s
211211
OPF_093=The "media-type" attribute is required for linked resources located in the EPUB container
212212
OPF_094=The "media-type" attribute is required for "%1$s" links.
213-
OPF_095=The "media-type" attribute of "voicing" links must be an audio MIME type, but found "%1$s".
213+
OPF_095=The "media-type" attribute of "voicing" links must be an audio MIME type, but found "%1$s".
214+
OPF_096=Non-linear content must be reachable, but found no hyperlink to "%1$s".
215+
OPF_096b=No hyperlink was found to non-linear document "%1$s", please check that it can be reached from scripted content.
214216

215217
#Package
216218
PKG_001=Validating the EPUB against version %1$s but detected version %2$s.
Collapse file

‎src/test/resources/epub-edupub/edupub-publication.feature‎

Copy file name to clipboardExpand all lines: src/test/resources/epub-edupub/edupub-publication.feature
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Feature: EPUB for Education ▸ Full Publication Checks
5151

5252
## 4.2 Sectioning
5353

54-
Scenario: Verify an non-linear content does not have to follow the sectioning rules
54+
Scenario: Verify that non-linear content does not have to follow the sectioning rules
5555
When checking EPUB 'edupub-non-linear-valid'
5656
Then no errors or warnings are reported
5757

Collapse file

‎src/test/resources/epub-edupub/files/epub/edupub-non-linear-valid/EPUB/nav.xhtml‎

Copy file name to clipboardExpand all lines: src/test/resources/epub-edupub/files/epub/edupub-non-linear-valid/EPUB/nav.xhtml
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<nav epub:type="toc">
99
<ol>
1010
<li><a href="content_001.xhtml">content 001</a></li>
11+
<li><a href="nonlinear.xhtml">non-linear</a></li>
1112
</ol>
1213
</nav>
1314
</body>
Collapse file

‎src/test/resources/epub-edupub/files/epub/edupub-non-linear-valid/EPUB/package.opf‎

Copy file name to clipboardExpand all lines: src/test/resources/epub-edupub/files/epub/edupub-non-linear-valid/EPUB/package.opf
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
<manifest>
1212
<item id="content_001" href="content_001.xhtml" media-type="application/xhtml+xml"/>
1313
<item id="nav" href="nav.xhtml" media-type="application/xhtml+xml" properties="nav"/>
14-
<item id="non" href="nonlinear.xhtml" media-type="application/xhtml+xml" />
14+
<item id="nonlinear" href="nonlinear.xhtml" media-type="application/xhtml+xml" />
1515
</manifest>
1616
<spine>
1717
<itemref idref="content_001" />
18-
<itemref idref="non" linear="no" />
18+
<itemref idref="nonlinear" linear="no" />
1919
</spine>
2020
</package>
Collapse file

‎src/test/resources/epub-region-nav/files/epub/data-nav-in-spine-warning/EPUB/nav.xhtml‎

Copy file name to clipboardExpand all lines: src/test/resources/epub-region-nav/files/epub/data-nav-in-spine-warning/EPUB/nav.xhtml
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<nav epub:type="toc">
99
<ol>
1010
<li><a href="content_001.xhtml">content 001</a></li>
11+
<li><a href="data-nav.xhtml">data nav</a></li>
1112
</ol>
1213
</nav>
1314
</body>
Collapse file

‎src/test/resources/epub3/05-package-document/files/spine-empty-error.opf‎

Copy file name to clipboard
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<package xmlns="http://www.idpf.org/2007/opf" version="3.0" xml:lang="en" unique-identifier="q">
3+
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/">
4+
<dc:title id="title">Minimal EPUB 3.0</dc:title>
5+
<dc:language>en</dc:language>
6+
<dc:identifier id="q">NOID</dc:identifier>
7+
<meta property="dcterms:modified">2017-06-14T00:00:01Z</meta>
8+
</metadata>
9+
<manifest>
10+
<item id="content_001" href="content_001.xhtml" media-type="application/xhtml+xml"/>
11+
<item id="nav" href="nav.xhtml" media-type="application/xhtml+xml" properties="nav"/>
12+
</manifest>
13+
<spine>
14+
<!-- <itemref idref="content_001" />-->
15+
</spine>
16+
</package>
Collapse file

‎…age-spine-missing-error/EPUB/package.opf‎ ‎…e-document/files/spine-missing-error.opf‎src/test/resources/epub3/05-package-document/files/package-spine-missing-error/EPUB/package.opf renamed to src/test/resources/epub3/05-package-document/files/spine-missing-error.opf src/test/resources/epub3/05-package-document/files/package-spine-missing-error/EPUB/package.opf renamed to src/test/resources/epub3/05-package-document/files/spine-missing-error.opf

Copy file name to clipboard
File renamed without changes.

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.