Skip to content

Commit 49412e0

Browse files
murata2makototofi86
authored andcommitted
Allowing aria role attributes in svg (#780)
fixes #769
1 parent 392c2f6 commit 49412e0

File tree

4 files changed

+308
-3
lines changed

4 files changed

+308
-3
lines changed

src/main/resources/com/adobe/epubcheck/schema/30/epub-svg-30.rnc

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

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

12+
include "./mod/html5/html5-aria-30.rnc"
13+
1214
include "./mod/datatypes.rnc"
1315
include "./mod/html5/html5-models-30.rnc"
1416

Original file line numberDiff line numberDiff line change
@@ -1,14 +1,296 @@
11
# $Id: epub-svg11-30.rnc 3093 2011-08-22 18:33:36Z markus.gylling@gmail.com $
22
# Contributors: MURATA Makoto and Markus Gylling
3+
default namespace = "http://www.w3.org/2000/svg"
34
namespace epub = "http://www.idpf.org/2007/ops"
4-
5+
namespace a = "http://relaxng.org/ns/compatibility/annotations/1.0"
6+
7+
SVG.aria.attr = parent aria.role.attr? & parent aria.global & parent aria.widget.excl & parent aria.relationship.excl
58
include "svg11/svg11-flat.rnc" {
69
start = svg
710
SVG.id.attrib = attribute id { parent datatype.ID }?
811
SVG.AnimationEvents.attrib = notAllowed
912
SVG.Animation.class = notAllowed
1013
SVG.foreignObject.extra.content = parent html5.flow.class
1114
SVG.title.extra.content = parent html5.phrasing.class
12-
SVG.Core.extra.attrib &= attribute epub:type { parent datatype.properties }?
13-
}
15+
SVG.Core.extra.attrib &= attribute epub:type { parent datatype.properties }?
1416

17+
a =
18+
element a {
19+
SVG.aria.attr,
20+
SVG.Core.attrib,
21+
SVG.Conditional.attrib,
22+
SVG.Style.attrib,
23+
SVG.Presentation.attrib,
24+
SVG.GraphicalEvents.attrib,
25+
SVG.XLinkReplace.attrib,
26+
SVG.External.attrib,
27+
attribute transform { TransformList.datatype }?,
28+
attribute target { LinkTarget.datatype }?,
29+
SVG.a.content
30+
}
31+
circle =
32+
element circle {
33+
SVG.aria.attr,
34+
SVG.Core.attrib,
35+
SVG.Conditional.attrib,
36+
SVG.Style.attrib,
37+
SVG.Presentation.attrib,
38+
SVG.GraphicalEvents.attrib,
39+
SVG.External.attrib,
40+
attribute cx { Coordinate.datatype }?,
41+
attribute cy { Coordinate.datatype }?,
42+
attribute r { Length.datatype },
43+
attribute transform { TransformList.datatype }?,
44+
SVG.circle.content
45+
}
46+
ellipse =
47+
element ellipse {
48+
SVG.aria.attr,
49+
SVG.Core.attrib,
50+
SVG.Conditional.attrib,
51+
SVG.Style.attrib,
52+
SVG.Presentation.attrib,
53+
SVG.GraphicalEvents.attrib,
54+
SVG.External.attrib,
55+
attribute cx { Coordinate.datatype }?,
56+
attribute cy { Coordinate.datatype }?,
57+
attribute rx { Length.datatype },
58+
attribute ry { Length.datatype },
59+
attribute transform { TransformList.datatype }?,
60+
SVG.ellipse.content
61+
}
62+
foreignObject =
63+
element foreignObject {
64+
SVG.aria.attr,
65+
SVG.Core.attrib,
66+
SVG.Conditional.attrib,
67+
SVG.Style.attrib,
68+
SVG.Presentation.attrib,
69+
SVG.GraphicalEvents.attrib,
70+
SVG.External.attrib,
71+
attribute x { Coordinate.datatype }?,
72+
attribute y { Coordinate.datatype }?,
73+
attribute width { Length.datatype },
74+
attribute height { Length.datatype },
75+
attribute transform { TransformList.datatype }?,
76+
SVG.foreignObject.content
77+
}
78+
g =
79+
element g {
80+
SVG.aria.attr,
81+
SVG.Core.attrib,
82+
SVG.Conditional.attrib,
83+
SVG.Style.attrib,
84+
SVG.Presentation.attrib,
85+
SVG.GraphicalEvents.attrib,
86+
SVG.External.attrib,
87+
attribute transform { TransformList.datatype }?,
88+
SVG.g.content
89+
}
90+
image =
91+
element image {
92+
SVG.aria.attr,
93+
SVG.Core.attrib,
94+
SVG.Conditional.attrib,
95+
SVG.Style.attrib,
96+
SVG.Presentation.attrib,
97+
SVG.GraphicalEvents.attrib,
98+
SVG.XLinkEmbed.attrib,
99+
SVG.External.attrib,
100+
attribute x { Coordinate.datatype }?,
101+
attribute y { Coordinate.datatype }?,
102+
attribute width { Length.datatype },
103+
attribute height { Length.datatype },
104+
[ a:defaultValue = "xMidYMid meet" ]
105+
attribute preserveAspectRatio { PreserveAspectRatioSpec.datatype }?,
106+
attribute transform { TransformList.datatype }?,
107+
SVG.image.content
108+
}
109+
line =
110+
element line {
111+
SVG.aria.attr,
112+
SVG.Core.attrib,
113+
SVG.Conditional.attrib,
114+
SVG.Style.attrib,
115+
SVG.Presentation.attrib,
116+
SVG.GraphicalEvents.attrib,
117+
SVG.External.attrib,
118+
attribute x1 { Coordinate.datatype }?,
119+
attribute y1 { Coordinate.datatype }?,
120+
attribute x2 { Coordinate.datatype }?,
121+
attribute y2 { Coordinate.datatype }?,
122+
attribute transform { TransformList.datatype }?,
123+
SVG.line.content
124+
}
125+
path =
126+
element path {
127+
SVG.aria.attr,
128+
SVG.Core.attrib,
129+
SVG.Conditional.attrib,
130+
SVG.Style.attrib,
131+
SVG.Presentation.attrib,
132+
SVG.GraphicalEvents.attrib,
133+
SVG.External.attrib,
134+
attribute d { PathData.datatype },
135+
attribute pathLength { Number.datatype }?,
136+
attribute transform { TransformList.datatype }?,
137+
SVG.path.content
138+
}
139+
polygon =
140+
element polygon {
141+
SVG.aria.attr,
142+
SVG.Core.attrib,
143+
SVG.Conditional.attrib,
144+
SVG.Style.attrib,
145+
SVG.Presentation.attrib,
146+
SVG.GraphicalEvents.attrib,
147+
SVG.External.attrib,
148+
attribute points { Points.datatype },
149+
attribute transform { TransformList.datatype }?,
150+
SVG.polygon.content
151+
}
152+
polyline =
153+
element polyline {
154+
SVG.aria.attr,
155+
SVG.Core.attrib,
156+
SVG.Conditional.attrib,
157+
SVG.Style.attrib,
158+
SVG.Presentation.attrib,
159+
SVG.GraphicalEvents.attrib,
160+
SVG.External.attrib,
161+
attribute points { Points.datatype },
162+
attribute transform { TransformList.datatype }?,
163+
SVG.polyline.content
164+
}
165+
rect =
166+
element rect {
167+
SVG.aria.attr,
168+
SVG.Core.attrib,
169+
SVG.Conditional.attrib,
170+
SVG.Style.attrib,
171+
SVG.Presentation.attrib,
172+
SVG.GraphicalEvents.attrib,
173+
SVG.External.attrib,
174+
attribute x { Coordinate.datatype }?,
175+
attribute y { Coordinate.datatype }?,
176+
attribute width { Length.datatype },
177+
attribute height { Length.datatype },
178+
attribute rx { Length.datatype }?,
179+
attribute ry { Length.datatype }?,
180+
attribute transform { TransformList.datatype }?,
181+
SVG.rect.content
182+
}
183+
svg =
184+
element svg {
185+
SVG.aria.attr,
186+
SVG.xmlns.attrib,
187+
SVG.Core.attrib,
188+
SVG.Conditional.attrib,
189+
SVG.Style.attrib,
190+
SVG.Presentation.attrib,
191+
SVG.DocumentEvents.attrib,
192+
SVG.GraphicalEvents.attrib,
193+
SVG.External.attrib,
194+
attribute x { Coordinate.datatype }?,
195+
attribute y { Coordinate.datatype }?,
196+
attribute width { Length.datatype }?,
197+
attribute height { Length.datatype }?,
198+
attribute viewBox { ViewBoxSpec.datatype }?,
199+
[ a:defaultValue = "xMidYMid meet" ]
200+
attribute preserveAspectRatio { PreserveAspectRatioSpec.datatype }?,
201+
[ a:defaultValue = "magnify" ]
202+
attribute zoomAndPan { "disable" | "magnify" }?,
203+
[ a:defaultValue = "1.1" ] attribute version { string "1.1" }?,
204+
attribute baseProfile { Text.datatype }?,
205+
[ a:defaultValue = "application/ecmascript" ]
206+
attribute contentScriptType { ContentType.datatype }?,
207+
[ a:defaultValue = "text/css" ]
208+
attribute contentStyleType { ContentType.datatype }?,
209+
SVG.svg.content
210+
}
211+
switch =
212+
element switch {
213+
SVG.aria.attr,
214+
SVG.Core.attrib,
215+
SVG.Conditional.attrib,
216+
SVG.Style.attrib,
217+
SVG.Presentation.attrib,
218+
SVG.GraphicalEvents.attrib,
219+
SVG.External.attrib,
220+
attribute transform { TransformList.datatype }?,
221+
SVG.switch.content
222+
}
223+
\text =
224+
element text {
225+
SVG.aria.attr,
226+
SVG.Core.attrib,
227+
SVG.Conditional.attrib,
228+
SVG.Style.attrib,
229+
SVG.Presentation.attrib,
230+
SVG.GraphicalEvents.attrib,
231+
SVG.External.attrib,
232+
attribute x { Coordinates.datatype }?,
233+
attribute y { Coordinates.datatype }?,
234+
attribute dx { Lengths.datatype }?,
235+
attribute dy { Lengths.datatype }?,
236+
attribute rotate { Numbers.datatype }?,
237+
attribute textLength { Length.datatype }?,
238+
attribute lengthAdjust { "spacing" | "spacingAndGlyphs" }?,
239+
attribute transform { TransformList.datatype }?,
240+
SVG.text.content
241+
}
242+
textPath =
243+
element textPath {
244+
SVG.aria.attr,
245+
SVG.Core.attrib,
246+
SVG.Conditional.attrib,
247+
SVG.Style.attrib,
248+
SVG.Presentation.attrib,
249+
SVG.GraphicalEvents.attrib,
250+
SVG.XLinkRequired.attrib,
251+
SVG.External.attrib,
252+
attribute startOffset { Length.datatype }?,
253+
attribute textLength { Length.datatype }?,
254+
attribute lengthAdjust { "spacing" | "spacingAndGlyphs" }?,
255+
attribute method { "align" | "stretch" }?,
256+
attribute spacing { "auto" | "exact" }?,
257+
SVG.textPath.content
258+
}
259+
tspan =
260+
element tspan {
261+
SVG.aria.attr,
262+
SVG.Core.attrib,
263+
SVG.Conditional.attrib,
264+
SVG.Style.attrib,
265+
SVG.Presentation.attrib,
266+
SVG.GraphicalEvents.attrib,
267+
SVG.External.attrib,
268+
attribute x { Coordinates.datatype }?,
269+
attribute y { Coordinates.datatype }?,
270+
attribute dx { Lengths.datatype }?,
271+
attribute dy { Lengths.datatype }?,
272+
attribute rotate { Numbers.datatype }?,
273+
attribute textLength { Length.datatype }?,
274+
attribute lengthAdjust { "spacing" | "spacingAndGlyphs" }?,
275+
SVG.tspan.content
276+
}
277+
use =
278+
element use {
279+
SVG.aria.attr,
280+
SVG.Core.attrib,
281+
SVG.Conditional.attrib,
282+
SVG.Style.attrib,
283+
SVG.Presentation.attrib,
284+
SVG.GraphicalEvents.attrib,
285+
SVG.XLinkEmbed.attrib,
286+
SVG.External.attrib,
287+
attribute x { Coordinate.datatype }?,
288+
attribute y { Coordinate.datatype }?,
289+
attribute width { Length.datatype }?,
290+
attribute height { Length.datatype }?,
291+
attribute transform { TransformList.datatype }?,
292+
SVG.use.content
293+
}
294+
}
295+
296+

src/test/java/com/adobe/epubcheck/ops/OPSCheckerTest.java

+8
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,14 @@ public void testValidateXHTMLIssue222_223_30()
677677
EPUBVersion.VERSION_3);
678678
}
679679

680+
@Test
681+
public void testValidateXHTMLSVGIssue769()
682+
{
683+
// allow aria attributes on SVG elements
684+
testValidateDocument("svg/valid/issue769.xhtml", "application/xhtml+xml",
685+
EPUBVersion.VERSION_3);
686+
}
687+
680688
@Test
681689
public void testValidateXHTMLIssue248()
682690
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<html xmlns="http://www.w3.org/1999/xhtml"
3+
xmlns:svg="http://www.w3.org/2000/svg">
4+
<head>
5+
<title>Aria attributes (like @role) on SVG elements are allowed</title>
6+
</head>
7+
<body>
8+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
9+
width="7.421ex" height="2.806ex" viewBox="0 -845 3195 1208.3" role="img">
10+
<image width="7.421ex" height="2.806ex" xlink:href=""/>
11+
</svg>
12+
</body>
13+
</html>

0 commit comments

Comments
 (0)