-
Notifications
You must be signed in to change notification settings - Fork 408
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
issue a warning when guide/reference elements are not unique // refs #…
…493 The OPF 2.0 schematron needed to be switched to ISO Schematron to be able to implement the test.
- Loading branch information
Showing
5 changed files
with
89 additions
and
2 deletions.
There are no files selected for viewing
17 changes: 15 additions & 2 deletions
17
src/main/resources/com/adobe/epubcheck/schema/20/sch/opf.sch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,27 @@ | ||
<sch:schema xmlns:sch="http://www.ascc.net/xml/schematron"> | ||
<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2"> | ||
|
||
<sch:ns prefix="dc" uri="http://purl.org/dc/elements/1.1/"/> | ||
<sch:ns prefix="opf" uri="http://www.idpf.org/2007/opf"/> | ||
|
||
<sch:pattern name="opf_idAttrUnique" id="opf_idAttrUnique"> | ||
<sch:pattern id="opf_idAttrUnique"> | ||
<!-- id attribute value must be unique for any id attribute in opf file--> | ||
<sch:rule context="//*[@id]"> | ||
<sch:assert test="count(//@id[normalize-space(.) = normalize-space(current()/@id)]) = 1">The | ||
"id" attribute does not have a unique value</sch:assert> | ||
</sch:rule> | ||
</sch:pattern> | ||
|
||
<sch:pattern id="opf_guideReferenceUnique"> | ||
<!-- guide/reference element should be unique (#493) --> | ||
<sch:rule context="opf:reference"> | ||
<sch:let name="current_type_normalized" value="normalize-space(lower-case(@type))"/> | ||
<sch:let name="current_href_normalized" value="normalize-space(lower-case(@href))"/> | ||
<sch:assert test=" | ||
count(//opf:reference[ | ||
normalize-space(lower-case(@type)) = $current_type_normalized and | ||
normalize-space(lower-case(@href)) = $current_href_normalized | ||
]) = 1">WARNING: Duplicate 'reference' elements with the same 'type' and 'href' attributes</sch:assert> | ||
</sch:rule> | ||
</sch:pattern> | ||
|
||
</sch:schema> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/test/resources/20/single/opf/invalid/guide-duplicates.opf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version='1.0' encoding='UTF-8'?> | ||
<package xmlns:opf="http://www.idpf.org/2007/opf" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.idpf.org/2007/opf" version="2.0" unique-identifier="id"> | ||
<metadata> | ||
<dc:rights>Public domain in the USA.</dc:rights> | ||
<dc:identifier id="id" opf:scheme="URI">http://www.gutenberg.org/ebooks/36582</dc:identifier> | ||
<dc:creator opf:file-as="Anonymous">Anonymous</dc:creator> | ||
<dc:title>Advice to Sunday School Children</dc:title> | ||
<dc:language xsi:type="dcterms:RFC4646">en</dc:language> | ||
<dc:date opf:event="publication">2011-07-02</dc:date> | ||
<dc:date opf:event="conversion">2011-07-03T19:26:31.417584+00:00</dc:date> | ||
<dc:source>http://www.gutenberg.org/files/36582/36582-h/36582-h.htm</dc:source> | ||
</metadata> | ||
<manifest> | ||
<item href="pgepub.css" id="item12" media-type="text/css"/> | ||
<item href="toc.ncx" id="ncx" media-type="application/x-dtbncx+xml"/> | ||
<item href="wrap0000.html" id="coverpage-wrapper" media-type="application/xhtml+xml"/> | ||
</manifest> | ||
<spine toc="ncx"> | ||
<itemref idref="coverpage-wrapper"/> | ||
</spine> | ||
<guide> | ||
<reference href="wrap0000.html" type="cover" title="Cover"/> | ||
<reference href="wrap0000.html" type="cover" title="Cover"/> | ||
</guide> | ||
</package> |
22 changes: 22 additions & 0 deletions
22
src/test/resources/30/single/opf/invalid/guide-duplicates.opf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<?oxygen RNGSchema="../../../src/schema/package-30.rnc" type="compact"?> | ||
<?oxygen SCHSchema="../../../src/schema/package-30.sch"?> | ||
<package xmlns="http://www.idpf.org/2007/opf" version="3.0" unique-identifier="uid" xmlns:dc="http://purl.org/dc/elements/1.1/"> | ||
<metadata> | ||
<dc:identifier id="uid">urn:uuid:550e8412-e29b-41d4-a716-446655441234</dc:identifier> | ||
<dc:title>Norwegian Wood</dc:title> | ||
<dc:language>en</dc:language> | ||
<meta property="dcterms:modified">2011-08-19T12:00:00Z</meta> | ||
</metadata> | ||
<manifest> | ||
<item id="t001" href="contents.xhtml" properties="nav" media-type="application/xhtml+xml" /> | ||
</manifest> | ||
<spine> | ||
<itemref idref="t001" /> | ||
</spine> | ||
<guide> | ||
<reference href="contents.xhtml" type="cover" title="Cover"/> | ||
<reference href="cover.xhtml" type="cover" title="Cover"/> | ||
<reference href="contents.xhtml" type="cover"/> | ||
</guide> | ||
</package> |