Skip to content

Commit

Permalink
feat: update XHTML, SVG and MathML schemas
Browse files Browse the repository at this point in the history
This is a major schema update, to reuse the latest schemas from
the Nu Html Checker, with the following tweaks:

- adapt the integration in schema drivers
- replace the Nu Html Checker's pluggable datatype library with
  EPUBCheck’s more limited static RelaxNG datatypes
- add EPUB-specific content model extensions

Changes specific to XHTML:

- keep allowing missing `title` in the `head` element
- but report missing `title` as a WARNING (with a Schematron check)
- keep allowing `meta http-equiv` in encoding declaration state
  (allowed in W3C but forbidden in WHATWG's HTML standard)
- keep allowing the `border` attribute on `table` elements
  (allowed in W3C but forbidden in WHATWG's HTML standard)
- report `aria-describedat` as a schema error
- add tests for several obsolete features which appeared in previous
  test content (`time/@pubdate`, `iframe/@seamless`, `keygen`, `menu`,
  `dropzone`, `contextmenu`, in-body `style`, `style/@scoped`)

Changes specific to MathML:

- use the schemas from Nu Html Checker, which are based on older
  MathML schema but bring some specific tweaks.
- re-add the changes from the newer MathML 3.0 (2nd edition) schemas
- improve the schema checks of EPUB-specific `annotation-xml`
  restrictions (notably check the combination of the `name` and
  `encoding` attributes)

Changes specific to SVG:

- use the schemas from Nu Html Checker, which are based SVG 1.1

Changes specific to Navigation Documents:

- do not check the presence of mandatory headings on `nav` elements
  with no `epub:type` attribute

Fixes #892
Fixes #779
Fixes #896
Fixes (partially?) #893
Closes #448
  • Loading branch information
rdeltour committed Jan 12, 2019
1 parent 9e95fce commit 47d4926
Show file tree
Hide file tree
Showing 243 changed files with 16,117 additions and 7,173 deletions.
34 changes: 24 additions & 10 deletions src/main/resources/com/adobe/epubcheck/schema/30/epub-nav-30.rnc
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,33 @@
namespace epub = "http://www.idpf.org/2007/ops"

include "epub-xhtml-30.rnc" {
html5.nav.attlist &= epub.nav.attrs
nav.attrs = nav.attrs.noepubtype
}

## "reset" the definition of nav.attrs to what it was
## before epub:type was set to augment common.attrs
nav.attrs.noepubtype =
( common.attrs.basic
& common.attrs.i18n
& common.attrs.present
& common.attrs.other
& ( common.attrs.aria.implicit.navigation
| common.attrs.aria.landmark.navigation
| common.attrs.aria.role.doc-index
| common.attrs.aria.role.doc-pagelist
| common.attrs.aria.role.doc-toc
)?
)

html5.headings.class = hgroup.elem | h1.elem | h2.elem | h3.elem | h4.elem | h5.elem | h6.elem

epub.nav.attrs &= html5.global.common.attrs & epub.nav.xml.attrs
epub.nav.xml.attrs &= html5.xml.lang.attr? & html5.xml.base.attr? & html5.xml.space.attr?

html5.sections.class |= epub.nav

epub.nav = element nav { epub.type.attr & epub.nav.attrs & epub.nav.content }
epub.nav = element nav { epub.type.attr & nav.attrs.noepubtype & epub.nav.content }
epub.nav.content = html5.headings.class?, epub.nav.ol

epub.nav.ol = element ol { html5.ol.attlist & epub.nav.ol.content }
epub.nav.ol = element ol { ol.attrs & epub.nav.ol.content }
epub.nav.ol.content = epub.nav.oli+

epub.nav.oli = element li { html5.oli.attlist & epub.nav.oli.content }
epub.nav.oli.content = html5.a.phrasing | ((html5.a.phrasing | html5.span), epub.nav.ol)
epub.nav.oli = element li { oli.attrs & epub.nav.oli.content }
epub.nav.oli.content = a.elem.phrasing | ((a.elem.phrasing | span.elem), epub.nav.ol)

common.elem.flow |= epub.nav
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@

<pattern id="req-heading">
<rule
context="html:nav[not(tokenize(@epub:type,'\s+') = ('toc','page-list','landmarks'))]">
context="html:nav[@epub:type][not(tokenize(@epub:type,'\s+') = ('toc','page-list','landmarks'))]">
<assert test="child::*[1][self::html:h1|self::html:h2|self::html:h3|self::html:h4|self::html:h5|self::html:h6]">nav
elements other than 'toc', 'page-list' and 'landmarks' must have a heading as their
first child</assert>
Expand Down
18 changes: 1 addition & 17 deletions src/main/resources/com/adobe/epubcheck/schema/30/epub-svg-30.rnc
Original file line number Diff line number Diff line change
@@ -1,17 +1 @@

namespace x = "http://www.w3.org/1999/xhtml"

include "./mod/html5/html5-grouping-30.rnc" inherit = x
include "./mod/html5/html5-phrasing-30.rnc" inherit = x
include "./mod/html5/html5-sections-30.rnc" inherit = x
include "./mod/html5/html5-style-30.rnc" inherit = x
include "./mod/epub-ssml-attrs.rnc"

include "./mod/html5/html5-attrib-30.rnc"

include "./mod/html5/html5-aria-30.rnc"

include "./mod/datatypes.rnc"
include "./mod/html5/html5-models-30.rnc"

start = external "mod/epub-svg11-30.rnc"
include "./mod/epub-svg11.rnc"
42 changes: 5 additions & 37 deletions src/main/resources/com/adobe/epubcheck/schema/30/epub-xhtml-30.rnc
Original file line number Diff line number Diff line change
@@ -1,39 +1,7 @@
## XHTML5
include "./mod/epub-xhtml.rnc"

## SVG and MathML


default namespace = "http://www.w3.org/1999/xhtml"

include "./mod/html5/html5-document-30.rnc"

include "./mod/html5/html5-sections-30.rnc"
include "./mod/html5/html5-grouping-30.rnc"
include "./mod/html5/html5-phrasing-30.rnc"
include "./mod/html5/html5-embed-30.rnc"

include "./mod/html5/html5-edit-30.rnc"
include "./mod/html5/html5-style-30.rnc"
include "./mod/html5/html5-script-30.rnc"
include "./mod/html5/html5-interactive-30.rnc"
include "./mod/html5/html5-forms-30.rnc"

include "./mod/html5/html5-attrib-30.rnc"
include "./mod/html5/html5-aria-30.rnc"
include "./mod/html5/html5-rdfa.rnc"
include "./mod/html5/html5-md.rnc"

include "./mod/datatypes.rnc"
include "./mod/html5/html5-models-30.rnc"

include "./mod/epub-xhtml-mathml3-30.rnc"
include "./mod/epub-xhtml-svg11-30.rnc"

include "./mod/epub-trigger.rnc"
include "./mod/epub-switch.rnc"

include "./mod/epub-type-attr.rnc"
include "./mod/epub-prefix-attr.rnc"
include "./mod/epub-ssml-attrs.rnc"

start = html5.html


include "./mod/epub-xhtml-mathml3.rnc"
include "./mod/epub-xhtml-svg11.rnc"
51 changes: 10 additions & 41 deletions src/main/resources/com/adobe/epubcheck/schema/30/epub-xhtml-30.sch
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@
the charset attribute present.</assert>
</rule>
</pattern>


<pattern id="title.present">
<rule context="h:head">
<assert test="exists(h:title)"
>WARNING: The 'head' element should have a 'title' child element.</assert>
</rule>
</pattern>

<pattern id="ancestor-area-map" is-a="required-ancestor">
<param name="descendant" value="h:area"/>
Expand Down Expand Up @@ -100,11 +108,6 @@
<param name="descendant" value="h:dfn"/>
</pattern>

<pattern id="descendant-time-time" is-a="disallowed-descendants">
<param name="ancestor" value="h:time"/>
<param name="descendant" value="h:time"/>
</pattern>

<pattern id="descendant-caption-table" is-a="disallowed-descendants">
<param name="ancestor" value="h:caption"/>
<param name="descendant" value="h:table"/>
Expand Down Expand Up @@ -191,12 +194,6 @@
<param name="idref-attr-name" value="indenttarget"/>
</pattern>

<pattern id="idref-contextmenu" is-a="idref-named">
<param name="element" value="h:*"/>
<param name="idref-attr-name" value="contextmenu"/>
<param name="target-name" value="h:menu"/>
</pattern>

<pattern id="idref-input-list" is-a="idref-named">
<param name="element" value="h:input"/>
<param name="idref-attr-name" value="list"/>
Expand All @@ -222,14 +219,13 @@
test="some $elem in $id-set satisfies $elem/@id eq current()/@for and
(local-name($elem) eq 'button'
or (local-name($elem) eq 'input' and not($elem/@type='hidden'))
or local-name($elem) eq 'keygen'
or local-name($elem) eq 'meter'
or local-name($elem) eq 'output'
or local-name($elem) eq 'progress'
or local-name($elem) eq 'select'
or local-name($elem) eq 'textarea')"
>The for attribute does not refer to an allowed target element (expecting:
button|keygen|meter|output|progress|select|textarea|input[not(@type='hidden')]).</assert>
button|meter|output|progress|select|textarea|input[not(@type='hidden')]).</assert>
</rule>
</pattern>

Expand Down Expand Up @@ -306,18 +302,6 @@
</rule>
</pattern>

<pattern id="style-scoped">
<rule context="h:style[ancestor::h:body]">
<!-- Note: this sch test is at risk as it is fragile and doesnt fully cover the
rules of http://dev.w3.org/html5/spec/single-page.html#attr-style-scoped.
See also https://www.w3.org/Bugs/Public/show_bug.cgi?id=13102 -->
<assert
test="every $elem in preceding-sibling::* satisfies (local-name($elem) eq 'style') or (local-name($elem) eq 'figcaption') "
>The scoped style element must occur before any other flow content other than other
style elements and inter-element whitespace.</assert>
</rule>
</pattern>

<pattern id="link-sizes">
<rule context="h:link[@sizes]">
<assert test="@rel='icon'">The sizes attribute must not be specified on link elements
Expand All @@ -332,21 +316,6 @@
</rule>
</pattern>

<pattern id="article-pubdate">
<rule context="h:article[h:time]">
<assert test="count(./h:time[@pubdate]) &lt; 2">For each article element, there must be
no more than one time element child with a pubdate attribute</assert>
</rule>
</pattern>

<pattern id="document-pubdate">
<rule context="h:time[not (ancestor::h:article)]">
<assert test="count(//h:time[@pubdate and not (ancestor::h:article)]) &lt; 2">For each
Document, there must be no more than one time element with a pubdate attribute that
does not have an ancestor article element.</assert>
</rule>
</pattern>

<pattern id="md-a-area">
<rule context="h:a[@itemprop] | h:area[@itemprop]">
<assert test="@href">If the itemprop is specified on an a element, then the href
Expand Down Expand Up @@ -419,7 +388,7 @@
<pattern abstract="true" id="no-interactive-content-descendants">
<rule
context="h:a|h:audio[@controls]|h:button|h:details|h:embed|h:iframe|h:img[@usemap]|h:input[not(@type='hidden')]
|h:keygen|h:label|h:menu[@type='toolbar']|h:object[@usemap]|h:select|h:textarea|h:video[@controls]">
|h:label|h:menu|h:object[@usemap]|h:select|h:textarea|h:video[@controls]">
<report test="ancestor::$ancestor">The <name/> element must not appear inside <value-of
select="local-name(ancestor::$ancestor)"/> elements.</report>
</rule>
Expand Down
Loading

0 comments on commit 47d4926

Please sign in to comment.