From 49412e05e43f6c993c6da652117cab005bc7e4cc Mon Sep 17 00:00:00 2001 From: MURATA Makoto Date: Mon, 17 Jul 2017 07:03:24 +0900 Subject: [PATCH] Allowing aria role attributes in svg (#780) fixes #769 --- .../adobe/epubcheck/schema/30/epub-svg-30.rnc | 2 + .../epubcheck/schema/30/mod/epub-svg11-30.rnc | 288 +++++++++++++++++- .../adobe/epubcheck/ops/OPSCheckerTest.java | 8 + .../30/single/svg/valid/issue769.xhtml | 13 + 4 files changed, 308 insertions(+), 3 deletions(-) create mode 100755 src/test/resources/30/single/svg/valid/issue769.xhtml diff --git a/src/main/resources/com/adobe/epubcheck/schema/30/epub-svg-30.rnc b/src/main/resources/com/adobe/epubcheck/schema/30/epub-svg-30.rnc index 42def251c..916e4dfeb 100644 --- a/src/main/resources/com/adobe/epubcheck/schema/30/epub-svg-30.rnc +++ b/src/main/resources/com/adobe/epubcheck/schema/30/epub-svg-30.rnc @@ -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" diff --git a/src/main/resources/com/adobe/epubcheck/schema/30/mod/epub-svg11-30.rnc b/src/main/resources/com/adobe/epubcheck/schema/30/mod/epub-svg11-30.rnc index 8254334e5..0718ccb72 100644 --- a/src/main/resources/com/adobe/epubcheck/schema/30/mod/epub-svg11-30.rnc +++ b/src/main/resources/com/adobe/epubcheck/schema/30/mod/epub-svg11-30.rnc @@ -1,7 +1,10 @@ # $Id: epub-svg11-30.rnc 3093 2011-08-22 18:33:36Z markus.gylling@gmail.com $ # 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 }? @@ -9,6 +12,285 @@ 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 + } + } + + \ No newline at end of file diff --git a/src/test/java/com/adobe/epubcheck/ops/OPSCheckerTest.java b/src/test/java/com/adobe/epubcheck/ops/OPSCheckerTest.java index 42d58830a..d93a8dd22 100644 --- a/src/test/java/com/adobe/epubcheck/ops/OPSCheckerTest.java +++ b/src/test/java/com/adobe/epubcheck/ops/OPSCheckerTest.java @@ -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() { diff --git a/src/test/resources/30/single/svg/valid/issue769.xhtml b/src/test/resources/30/single/svg/valid/issue769.xhtml new file mode 100755 index 000000000..1ecbc62e7 --- /dev/null +++ b/src/test/resources/30/single/svg/valid/issue769.xhtml @@ -0,0 +1,13 @@ + + + +Aria attributes (like @role) on SVG elements are allowed + + + + + + + \ No newline at end of file