W3C home > Mailing lists > Public > www-svg@w3.org > June 2011

Re: <switch>

From: Doug Schepers <schepers@w3.org>
Date: Thu, 23 Jun 2011 11:59:46 -0400
Message-ID: <4E0362F2.1020307@w3.org>
To: Erik Dahlstrom <ed@opera.com>
CC: "www-svg@w3.org" <www-svg@w3.org>
Hi, Erik-

I was thinking about <switch> just yesterday, in the context of a 
fallback for inline SVG in HTML.  I often hear questions about how to 
offer a fallback to SVG content, and HTML doesn't offer a very good 
story here

Something like this is very clumsy:

<!DOCTYPE html>
<html lang="en">
   <meta charset="utf-8"/>
   <title>SVG Fallback in HTML</title>

   <p>SVG Fallback in HTML</p>

   <svg xmlns="http://www.w3.org/2000/svg" width="200" height="200">
       <g requiredFeatures="http://www.w3.org/TR/SVG11/feature#SVG">
         <circle cx="55" cy="55" r="50" fill="blue"/>
       <foreignObject x="50" y="50" width="150" height="150">
         <div xmlns="http://www.w3.org/1999/xhtml">
           <img src="blue_circle.jpg"></img>

   <p>There should be a blue circle above</p>


I think it would be nice to have the reverse of @requiredFeatures... 
something like @unless, where the first content is displayed unless the 
condition applies, not if the condition applies.

But maybe that's drilling too far down into funky aspects of the same 
model... we should start collecting real-world use-cases and 
requirements and make sure they can be  solved with <switch>.  The uses 
I've wanted it for seem quite different than those the SYMM WG took into 
account, so I'd like to reboot it for SVG2 content that is focused on 
Web documents and applications, not just media applications.


Erik Dahlstrom wrote (on 6/23/11 8:01 AM):
> Hello,
> I'm wondering what good is the <switch> element if it doesn't seem to
> read the requiredFeatures attribute from unknown elements.
> Additionally it doesn't fully disable processing of the non-chosen
> subtrees, as illustrated by the audio/video example below.
> Questions:
> * What should happen in the switch below?
> * Should the audio from the video be heard?
> * Should the requiredFeatures attributes be used by the switch even
> though these elements
> are unknown? Or is requiredFeatures only possible on svg elements that
> the UA knows about?
> * Given the current state of implementations <switch> is very close to
> useless, how do we want to proceed wrt this for SVG2?
> Example:
> <svg xmlns='http://www.w3.org/2000/svg'
> xmlns:xlink='http://www.w3.org/1999/xlink' viewBox="0 0 400 400"
> id="svgroot">
> <text x="200" y="40" text-anchor="middle" font-size="9">You should see a
> video in the rectangle below if your browser supports
> <tspan x="200" dy="1.5em">foreignObject, HTML5 video and Ogg Theora
> (maybe).</tspan></text>
> <rect x="100" y="100" width="200" height="200" stroke-width="4"
> stroke="black" fill="none"/>
> <switch>
> <myCustomFooElement xmlns="http://example.com/foobarML" width="400"
> height="400" fill="red" requiredFeatures="bar"/>
> <aNewSvg5Element width="400" height="400" fill="red"
> requiredFeatures="SVG5featurestring"/>
> <foreignObject id="fo" x="100" y="100" width="200" height="200">
> <div xmlns="http://www.w3.org/1999/xhtml">
> <video width="200" height="200" autoplay="autoplay" controls="controls">
> <source src="example.ogv" type='video/ogg; codecs="theora, vorbis"'/>
> </video>
> </div>
> </foreignObject>
> </switch>
> </svg>
Received on Thursday, 23 June 2011 15:59:50 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 8 March 2017 09:47:25 UTC