Skip to content

Commit

Permalink
Allowing aria role attributes in svg (#780)
Browse files Browse the repository at this point in the history
fixes #769
  • Loading branch information
murata2makoto authored and tofi86 committed Jul 16, 2017
1 parent 392c2f6 commit 49412e0
Show file tree
Hide file tree
Showing 4 changed files with 308 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

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"

Expand Down
288 changes: 285 additions & 3 deletions src/main/resources/com/adobe/epubcheck/schema/30/mod/epub-svg11-30.rnc
Original file line number Diff line number Diff line change
@@ -1,14 +1,296 @@
# $Id: epub-svg11-30.rnc 3093 2011-08-22 18:33:36Z [email protected] $
# Contributors: MURATA Makoto and Markus Gylling
default namespace = "http://www.w3.org/2000/svg"
namespace epub = "http://www.idpf.org/2007/ops"

namespace a = "http://relaxng.org/ns/compatibility/annotations/1.0"

SVG.aria.attr = parent aria.role.attr? & parent aria.global & parent aria.widget.excl & parent aria.relationship.excl
include "svg11/svg11-flat.rnc" {
start = svg
SVG.id.attrib = attribute id { parent datatype.ID }?
SVG.AnimationEvents.attrib = notAllowed
SVG.Animation.class = notAllowed
SVG.foreignObject.extra.content = parent html5.flow.class
SVG.title.extra.content = parent html5.phrasing.class
SVG.Core.extra.attrib &= attribute epub:type { parent datatype.properties }?
}
SVG.Core.extra.attrib &= attribute epub:type { parent datatype.properties }?

a =
element a {
SVG.aria.attr,
SVG.Core.attrib,
SVG.Conditional.attrib,
SVG.Style.attrib,
SVG.Presentation.attrib,
SVG.GraphicalEvents.attrib,
SVG.XLinkReplace.attrib,
SVG.External.attrib,
attribute transform { TransformList.datatype }?,
attribute target { LinkTarget.datatype }?,
SVG.a.content
}
circle =
element circle {
SVG.aria.attr,
SVG.Core.attrib,
SVG.Conditional.attrib,
SVG.Style.attrib,
SVG.Presentation.attrib,
SVG.GraphicalEvents.attrib,
SVG.External.attrib,
attribute cx { Coordinate.datatype }?,
attribute cy { Coordinate.datatype }?,
attribute r { Length.datatype },
attribute transform { TransformList.datatype }?,
SVG.circle.content
}
ellipse =
element ellipse {
SVG.aria.attr,
SVG.Core.attrib,
SVG.Conditional.attrib,
SVG.Style.attrib,
SVG.Presentation.attrib,
SVG.GraphicalEvents.attrib,
SVG.External.attrib,
attribute cx { Coordinate.datatype }?,
attribute cy { Coordinate.datatype }?,
attribute rx { Length.datatype },
attribute ry { Length.datatype },
attribute transform { TransformList.datatype }?,
SVG.ellipse.content
}
foreignObject =
element foreignObject {
SVG.aria.attr,
SVG.Core.attrib,
SVG.Conditional.attrib,
SVG.Style.attrib,
SVG.Presentation.attrib,
SVG.GraphicalEvents.attrib,
SVG.External.attrib,
attribute x { Coordinate.datatype }?,
attribute y { Coordinate.datatype }?,
attribute width { Length.datatype },
attribute height { Length.datatype },
attribute transform { TransformList.datatype }?,
SVG.foreignObject.content
}
g =
element g {
SVG.aria.attr,
SVG.Core.attrib,
SVG.Conditional.attrib,
SVG.Style.attrib,
SVG.Presentation.attrib,
SVG.GraphicalEvents.attrib,
SVG.External.attrib,
attribute transform { TransformList.datatype }?,
SVG.g.content
}
image =
element image {
SVG.aria.attr,
SVG.Core.attrib,
SVG.Conditional.attrib,
SVG.Style.attrib,
SVG.Presentation.attrib,
SVG.GraphicalEvents.attrib,
SVG.XLinkEmbed.attrib,
SVG.External.attrib,
attribute x { Coordinate.datatype }?,
attribute y { Coordinate.datatype }?,
attribute width { Length.datatype },
attribute height { Length.datatype },
[ a:defaultValue = "xMidYMid meet" ]
attribute preserveAspectRatio { PreserveAspectRatioSpec.datatype }?,
attribute transform { TransformList.datatype }?,
SVG.image.content
}
line =
element line {
SVG.aria.attr,
SVG.Core.attrib,
SVG.Conditional.attrib,
SVG.Style.attrib,
SVG.Presentation.attrib,
SVG.GraphicalEvents.attrib,
SVG.External.attrib,
attribute x1 { Coordinate.datatype }?,
attribute y1 { Coordinate.datatype }?,
attribute x2 { Coordinate.datatype }?,
attribute y2 { Coordinate.datatype }?,
attribute transform { TransformList.datatype }?,
SVG.line.content
}
path =
element path {
SVG.aria.attr,
SVG.Core.attrib,
SVG.Conditional.attrib,
SVG.Style.attrib,
SVG.Presentation.attrib,
SVG.GraphicalEvents.attrib,
SVG.External.attrib,
attribute d { PathData.datatype },
attribute pathLength { Number.datatype }?,
attribute transform { TransformList.datatype }?,
SVG.path.content
}
polygon =
element polygon {
SVG.aria.attr,
SVG.Core.attrib,
SVG.Conditional.attrib,
SVG.Style.attrib,
SVG.Presentation.attrib,
SVG.GraphicalEvents.attrib,
SVG.External.attrib,
attribute points { Points.datatype },
attribute transform { TransformList.datatype }?,
SVG.polygon.content
}
polyline =
element polyline {
SVG.aria.attr,
SVG.Core.attrib,
SVG.Conditional.attrib,
SVG.Style.attrib,
SVG.Presentation.attrib,
SVG.GraphicalEvents.attrib,
SVG.External.attrib,
attribute points { Points.datatype },
attribute transform { TransformList.datatype }?,
SVG.polyline.content
}
rect =
element rect {
SVG.aria.attr,
SVG.Core.attrib,
SVG.Conditional.attrib,
SVG.Style.attrib,
SVG.Presentation.attrib,
SVG.GraphicalEvents.attrib,
SVG.External.attrib,
attribute x { Coordinate.datatype }?,
attribute y { Coordinate.datatype }?,
attribute width { Length.datatype },
attribute height { Length.datatype },
attribute rx { Length.datatype }?,
attribute ry { Length.datatype }?,
attribute transform { TransformList.datatype }?,
SVG.rect.content
}
svg =
element svg {
SVG.aria.attr,
SVG.xmlns.attrib,
SVG.Core.attrib,
SVG.Conditional.attrib,
SVG.Style.attrib,
SVG.Presentation.attrib,
SVG.DocumentEvents.attrib,
SVG.GraphicalEvents.attrib,
SVG.External.attrib,
attribute x { Coordinate.datatype }?,
attribute y { Coordinate.datatype }?,
attribute width { Length.datatype }?,
attribute height { Length.datatype }?,
attribute viewBox { ViewBoxSpec.datatype }?,
[ a:defaultValue = "xMidYMid meet" ]
attribute preserveAspectRatio { PreserveAspectRatioSpec.datatype }?,
[ a:defaultValue = "magnify" ]
attribute zoomAndPan { "disable" | "magnify" }?,
[ a:defaultValue = "1.1" ] attribute version { string "1.1" }?,
attribute baseProfile { Text.datatype }?,
[ a:defaultValue = "application/ecmascript" ]
attribute contentScriptType { ContentType.datatype }?,
[ a:defaultValue = "text/css" ]
attribute contentStyleType { ContentType.datatype }?,
SVG.svg.content
}
switch =
element switch {
SVG.aria.attr,
SVG.Core.attrib,
SVG.Conditional.attrib,
SVG.Style.attrib,
SVG.Presentation.attrib,
SVG.GraphicalEvents.attrib,
SVG.External.attrib,
attribute transform { TransformList.datatype }?,
SVG.switch.content
}
\text =
element text {
SVG.aria.attr,
SVG.Core.attrib,
SVG.Conditional.attrib,
SVG.Style.attrib,
SVG.Presentation.attrib,
SVG.GraphicalEvents.attrib,
SVG.External.attrib,
attribute x { Coordinates.datatype }?,
attribute y { Coordinates.datatype }?,
attribute dx { Lengths.datatype }?,
attribute dy { Lengths.datatype }?,
attribute rotate { Numbers.datatype }?,
attribute textLength { Length.datatype }?,
attribute lengthAdjust { "spacing" | "spacingAndGlyphs" }?,
attribute transform { TransformList.datatype }?,
SVG.text.content
}
textPath =
element textPath {
SVG.aria.attr,
SVG.Core.attrib,
SVG.Conditional.attrib,
SVG.Style.attrib,
SVG.Presentation.attrib,
SVG.GraphicalEvents.attrib,
SVG.XLinkRequired.attrib,
SVG.External.attrib,
attribute startOffset { Length.datatype }?,
attribute textLength { Length.datatype }?,
attribute lengthAdjust { "spacing" | "spacingAndGlyphs" }?,
attribute method { "align" | "stretch" }?,
attribute spacing { "auto" | "exact" }?,
SVG.textPath.content
}
tspan =
element tspan {
SVG.aria.attr,
SVG.Core.attrib,
SVG.Conditional.attrib,
SVG.Style.attrib,
SVG.Presentation.attrib,
SVG.GraphicalEvents.attrib,
SVG.External.attrib,
attribute x { Coordinates.datatype }?,
attribute y { Coordinates.datatype }?,
attribute dx { Lengths.datatype }?,
attribute dy { Lengths.datatype }?,
attribute rotate { Numbers.datatype }?,
attribute textLength { Length.datatype }?,
attribute lengthAdjust { "spacing" | "spacingAndGlyphs" }?,
SVG.tspan.content
}
use =
element use {
SVG.aria.attr,
SVG.Core.attrib,
SVG.Conditional.attrib,
SVG.Style.attrib,
SVG.Presentation.attrib,
SVG.GraphicalEvents.attrib,
SVG.XLinkEmbed.attrib,
SVG.External.attrib,
attribute x { Coordinate.datatype }?,
attribute y { Coordinate.datatype }?,
attribute width { Length.datatype }?,
attribute height { Length.datatype }?,
attribute transform { TransformList.datatype }?,
SVG.use.content
}
}


8 changes: 8 additions & 0 deletions src/test/java/com/adobe/epubcheck/ops/OPSCheckerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,14 @@ public void testValidateXHTMLIssue222_223_30()
EPUBVersion.VERSION_3);
}

@Test
public void testValidateXHTMLSVGIssue769()
{
// allow aria attributes on SVG elements
testValidateDocument("svg/valid/issue769.xhtml", "application/xhtml+xml",
EPUBVersion.VERSION_3);
}

@Test
public void testValidateXHTMLIssue248()
{
Expand Down
13 changes: 13 additions & 0 deletions src/test/resources/30/single/svg/valid/issue769.xhtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:svg="http://www.w3.org/2000/svg">
<head>
<title>Aria attributes (like @role) on SVG elements are allowed</title>
</head>
<body>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
width="7.421ex" height="2.806ex" viewBox="0 -845 3195 1208.3" role="img">
<image width="7.421ex" height="2.806ex" xlink:href=""/>
</svg>
</body>
</html>

0 comments on commit 49412e0

Please sign in to comment.