-
Notifications
You must be signed in to change notification settings - Fork 405
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: check
epub:type
restrictions in XHTML and SVG
This commit refactors the RelaxNG XHTML and SVG schemas to check that the `epub:type` attribute is only allowed on: - palpable content in XHTML - structural, shape, and text elements in SVG It also reorganizes and renames the schemas in a slightly more consistent way. Fixes #1348
- Loading branch information
Showing
32 changed files
with
700 additions
and
358 deletions.
There are no files selected for viewing
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
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
2 changes: 1 addition & 1 deletion
2
...check/schema/30/epub-svg-informative.nvdl → ...ck/schema/30/epub-svg-30-informative.nvdl
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
17 changes: 17 additions & 0 deletions
17
src/main/resources/com/adobe/epubcheck/schema/30/epub-svg-30-informative.rnc
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,17 @@ | ||
namespace svg = "http://www.w3.org/2000/svg" | ||
|
||
# ##################################################################### | ||
## RELAX NG Schema for EPUB: EPUB SVG and XHTML (+ MathML) # | ||
## strict SVG grammar check (informative only) # | ||
# ##################################################################### | ||
|
||
include "./mod/epub-xhtml-inc.rnc" { | ||
# This schema applies both to XHTML and SVG documents | ||
start = svg | html.elem | ||
} | ||
include "./mod/epub-svg-strict-inc.rnc" | ||
include "./mod/epub-mathml3-inc.rnc" | ||
include "./mod/epub-shared-inc.rnc" | ||
|
||
common.elem.phrasing |= svg | ||
common.elem.phrasing |= math |
23 changes: 10 additions & 13 deletions
23
src/main/resources/com/adobe/epubcheck/schema/30/epub-svg-30.rnc
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,17 +1,14 @@ | ||
namespace svg = "http://www.w3.org/2000/svg" | ||
|
||
include "./mod/epub-xhtml-inc.rnc" { | ||
# ##################################################################### | ||
## RELAX NG Schema for EPUB: EPUB SVG (+ XHTML, + MathML) # | ||
# ##################################################################### | ||
|
||
include "./mod/epub-xhtml-svg-mathml.rnc" { | ||
start = svg | ||
|
||
# Override the `id` attribute to require a valid XML ID | ||
svg.attr.id = attribute id { xsd:ID }? | ||
} | ||
include "./mod/epub-mathml3.rnc" | ||
include "./mod/epub-svg-inc.rnc" | ||
|
||
svg.title.content |= common.inner.anyhtml | ||
|
||
svg.foreignObject.content |= | ||
( body.elem | ||
| common.inner.flow | ||
| math | ||
) | ||
|
||
mtext.content |= common.elem.phrasing | ||
# Allow `body` element as a child of `foreignObject` | ||
svg.foreignObject.inner |= body.elem |
21 changes: 0 additions & 21 deletions
21
src/main/resources/com/adobe/epubcheck/schema/30/epub-svg-informative.rnc
This file was deleted.
Oops, something went wrong.
21 changes: 4 additions & 17 deletions
21
src/main/resources/com/adobe/epubcheck/schema/30/epub-xhtml-30.rnc
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,19 +1,6 @@ | ||
namespace svg = "http://www.w3.org/2000/svg" | ||
|
||
include "./mod/epub-xhtml-inc.rnc" | ||
include "./mod/epub-mathml3.rnc" | ||
include "./mod/epub-svg-inc.rnc" { | ||
svg.attr.id = attribute id { datatype.html5.token }? | ||
} | ||
# ##################################################################### | ||
## RELAX NG Schema for EPUB: EPUB XHTML (+ SVG, + MathML) # | ||
# ##################################################################### | ||
|
||
common.elem.phrasing |= svg | ||
common.elem.phrasing |= math | ||
|
||
math.attributes &= aria.global? | ||
|
||
svg.title.content |= common.inner.anyhtml | ||
|
||
svg.foreignObject.content |= | ||
( common.inner.flow | ||
| math | ||
) | ||
include "./mod/epub-xhtml-svg-mathml.rnc" |
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
22 changes: 16 additions & 6 deletions
22
src/main/resources/com/adobe/epubcheck/schema/30/mod/epub-prefix-attr.rnc
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,8 +1,18 @@ | ||
|
||
namespace epub = "http://www.idpf.org/2007/ops" | ||
|
||
namespace epub = "http://www.idpf.org/2007/ops" | ||
|
||
html.attrs &= epub.prefix.attr.ns? | ||
|
||
epub.prefix.attr = attribute prefix { datatype.prefixdecl } | ||
epub.prefix.attr.ns = attribute epub:prefix { datatype.prefixdecl } | ||
# ##################################################################### | ||
## RELAX NG Schema for EPUB: EPUB prefix attributes # | ||
# ##################################################################### | ||
|
||
## prefix attributes | ||
|
||
epub.prefix.attr = | ||
attribute prefix { | ||
datatype.prefixdecl | ||
} | ||
|
||
epub.prefix.attr.ns = | ||
attribute epub:prefix { | ||
datatype.prefixdecl | ||
} |
29 changes: 29 additions & 0 deletions
29
src/main/resources/com/adobe/epubcheck/schema/30/mod/epub-shared-inc.rnc
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,29 @@ | ||
|
||
# ##################################################################### | ||
## RELAX NG Schema for EPUB: shared definitions for inclusion # | ||
# ##################################################################### | ||
|
||
## Includes | ||
|
||
# EPUB elements | ||
include "./epub-trigger.rnc" | ||
include "./epub-switch.rnc" | ||
|
||
# EPUB attributes | ||
include "./epub-prefix-attr.rnc" | ||
include "./epub-ssml-attrs.rnc" | ||
include "./epub-type-attr.rnc" | ||
|
||
# EPUB integration logic | ||
include "./epub-xhtml-integration.rnc" | ||
|
||
## Content model: HTML fragments | ||
|
||
# Note: the default HMTL schema does not define such a category, so we | ||
# do our best to include what makes sense here | ||
|
||
common.inner.anyhtml = | ||
html.elem | ||
| body.elem | ||
| common.inner.flow | ||
|
27 changes: 18 additions & 9 deletions
27
src/main/resources/com/adobe/epubcheck/schema/30/mod/epub-ssml-attrs.rnc
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,11 +1,20 @@ | ||
|
||
|
||
namespace epub = "http://www.idpf.org/2007/ops" | ||
namespace ssml = "http://www.w3.org/2001/10/synthesis" | ||
|
||
|
||
common.attrs.other &= epub.ssml.ph.attr? & epub.ssml.alphabet.attr? | ||
|
||
#TODO determine injection in SVG | ||
|
||
epub.ssml.ph.attr = attribute ssml:ph { datatype.ssml.PhoneticExpression } | ||
epub.ssml.alphabet.attr = attribute ssml:alphabet { datatype.ssml.PhoneticAlphabet } | ||
|
||
# ##################################################################### | ||
## RELAX NG Schema for EPUB: EPUB SSML attributes # | ||
# ##################################################################### | ||
|
||
|
||
## SSML attributes | ||
|
||
epub.ssml.ph.attr = | ||
attribute ssml:ph { | ||
datatype.ssml.PhoneticExpression | ||
} | ||
|
||
epub.ssml.alphabet.attr = | ||
attribute ssml:alphabet { | ||
datatype.ssml.PhoneticAlphabet | ||
} |
Oops, something went wrong.