Skip to content

Commit e3ffc37

Browse files
authored
fix: allow foreign namespaces in EPUB 2 SVGs
* allow foreign namespaced elements and attributes in EPUB 2 SVGs * Remove the restriction to HTML on foreignObject as that is an epub 3-specific rule
1 parent 929806b commit e3ffc37

File tree

4 files changed

+55
-5
lines changed

4 files changed

+55
-5
lines changed

src/main/java/com/adobe/epubcheck/ops/OPSChecker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public class OPSChecker implements ContentChecker, DocumentValidator
5656
.putAll(Predicates.and(mimetype("application/xhtml+xml"), version(EPUBVersion.VERSION_3)),
5757
XMLValidators.XHTML_30_RNC, XMLValidators.XHTML_30_SCH)
5858
.putAll(Predicates.and(mimetype("image/svg+xml"), version(EPUBVersion.VERSION_2)),
59-
XMLValidators.SVG_20_RNG, XMLValidators.IDUNIQUE_20_SCH)
59+
XMLValidators.SVG_20_NVDL, XMLValidators.IDUNIQUE_20_SCH)
6060
.putAll(Predicates.and(mimetype("image/svg+xml"), version(EPUBVersion.VERSION_3)),
6161
XMLValidators.SVG_30_NVDL)
6262
.putAll(

src/main/java/com/adobe/epubcheck/xml/XMLValidators.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public enum XMLValidators
3636
SEARCH_KEY_MAP_RNC("schema/30/dict/search-key-map.rnc"),
3737
SIG_20_RNG("schema/20/rng/signatures.rng"),
3838
SIG_30_RNC("schema/30/ocf-signatures-30.rnc"),
39-
SVG_20_RNG("schema/20/rng/svg11.rng"),
39+
SVG_20_NVDL("schema/20/rng/ops20-svg.nvdl"),
4040
SVG_30_RNC("schema/30/epub-svg-30.rnc"),
4141
SVG_30_NVDL("schema/30/epub-svg-30.nvdl"),
4242
SVG_30_SCH("schema/30/epub-svg-30.sch"),
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<rules xmlns="http://purl.oclc.org/dsdl/nvdl/ns/structure/1.0" startMode="svg">
3+
<mode name="svg">
4+
<namespace ns="http://www.w3.org/2000/svg">
5+
<validate schema="svg11.rng" schemaType="application/relax-ng"
6+
useMode="allowForeignNS">
7+
</validate>
8+
</namespace>
9+
</mode>
10+
<mode name="allowForeignNS">
11+
<namespace ns="http://www.w3.org/1999/xhtml">
12+
<attach/>
13+
</namespace>
14+
<namespace ns="http://www.idpf.org/2007/ops" match="attributes">
15+
<attach/>
16+
</namespace>
17+
<namespace ns="http://www.w3.org/1999/xlink" match="attributes">
18+
<attach/>
19+
</namespace>
20+
<namespace ns="http://www.w3.org/XML/1998/namespace" match="attributes">
21+
<attach/>
22+
</namespace>
23+
<namespace ns="" match="attributes">
24+
<attach/>
25+
</namespace>
26+
<anyNamespace match="elements attributes">
27+
<allow/>
28+
</anyNamespace>
29+
</mode>
30+
</rules>

src/main/resources/com/adobe/epubcheck/schema/20/rng/ops20.nvdl

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<!-- mode that allows arbitrary XHTML or SVG fragment -->
1313
<mode name="blessed-xhtml-svg">
1414
<namespace ns="http://www.w3.org/2000/svg">
15-
<allow/>
15+
<allow useMode="allowForeignNS"/>
1616
</namespace>
1717
<namespace ns="http://www.w3.org/1999/xhtml">
1818
<allow/>
@@ -27,7 +27,7 @@
2727
<attach/>
2828
</namespace>
2929
<namespace ns="http://www.w3.org/2000/svg">
30-
<attach/>
30+
<attach useMode="allowForeignNS"/>
3131
</namespace>
3232
<anyNamespace>
3333
<allow/>
@@ -46,7 +46,7 @@
4646
<!-- mode that validates SVG and OPS islands inside XHTML -->
4747
<mode name="xhtml-content">
4848
<namespace ns="http://www.w3.org/2000/svg">
49-
<attach/>
49+
<attach useMode="allowForeignNS"/>
5050
</namespace>
5151
<namespace ns="http://www.w3.org/1999/xhtml">
5252
<attach/>
@@ -67,4 +67,24 @@
6767
</namespace>
6868
</mode>
6969

70+
<mode name="allowForeignNS">
71+
<namespace ns="http://www.w3.org/1999/xhtml">
72+
<attach/>
73+
</namespace>
74+
<namespace ns="http://www.idpf.org/2007/ops" match="attributes">
75+
<attach/>
76+
</namespace>
77+
<namespace ns="http://www.w3.org/1999/xlink" match="attributes">
78+
<attach/>
79+
</namespace>
80+
<namespace ns="http://www.w3.org/XML/1998/namespace" match="attributes">
81+
<attach/>
82+
</namespace>
83+
<namespace ns="" match="attributes">
84+
<attach/>
85+
</namespace>
86+
<anyNamespace match="elements attributes">
87+
<allow/>
88+
</anyNamespace>
89+
</mode>
7090
</rules>

0 commit comments

Comments
 (0)