Re: SVG in HTML proposal

On Tue, 15 Jul 2008 04:20:25 +0200, Jeff Schiller <codedread@gmail.com> wrote:

> 1) Copying SVG documents from an SVG editor to an HTML document won't
> magically prefix name-clashed elements.  SVG fragments currently inline in
> XHTML documents won't be magically prefixed either.  I guess users would
> have to do that manually?  This seems to violate requirement #2.
>
> This might be fixable eventually in editors currently under active
> development, but what about Adobe Illustrator, for example?  

For the few elements where it actually makes a major visual difference (e.g textArea), yes you need to do prefixing - if and only if you don't want the content to look weird in legacy user agents. That's why prefixing elements is a recommendation to authors rather than a requirement. The next questions is: does Illustrator actually export 'textArea' elements?

Having <svg:a> be interpreted by a legacy user agent as <html:a> is perhaps not that critical, you can even add a 'src' attribute to have the link work in both contexts, so it can be used as a sort of fallback.

An <svg:title> is unlikely to cause any major problems if interpreted as <html:title>, <svg:font> may cause a legacy user agent to render its textcontent in some unexpected way (though there are few svgfonts that have much textcontent except for whitespace).

For <svg:script> and <svg:style> they are meant to be compatible with the XHTML counterparts, so only in the case where you really want to make sure they're not executed/applied do you need to prefix them.

> Manual author intervention + tutorials?

An author may have to tweak the content if it is to fallback gracefully, yes.

> It also, frankly, sucks for hand-authoring - since I have to put that prefix
> and namespace declaration on every element (the way it's described in the
> document)  Might I at least suggest something like this instead:
>
> <html><body>
>    <svg xmlns="http://www.w3.org/2000/svg" xmlns:svg="
> http://www.w3.org/2000/svg" ...>
>       <svg:title.../>
>       <circle .../>
>       <svg:a ... />
>    </svg>
> </body></html>

The proposal didn't say anything about adding the prefix declaration on every element it's used on, if the example gave that impression it was unintentional.

> 2) If my SVG has a foreignObject with HTML in it, and the browser does not
> handle SVG yet, then the contents of that foreignObject will be
> inadvertently rendered by the UA, which might not be desired.  Any
> recommendation for that?   html: prefix for all elements?

Sure, using prefixes is one way of dealing with that problem.

Other possible solutions:
- svg:script or svg:style that turns the display on for <svg> and removes the replacement image from the document
- use CSS Namespaces to detect if the element was given the proper namespace

<!DOCTYPE html>
<html>
<head>
<title>foo</title>
<style>
@namespace svg "http://www.w3.org/2000/svg";
foreignObject { display:none }
svg|foreignObject { display:inline; }
</style>
</head>
  <body>
hello
<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100">
<foreignObject>
<div style="width:100px;height:100px;background:red">red</div>
</foreignObject>
hello
</body>
</html>

Cheers
/Erik

-- 
Erik Dahlstrom, Core Technology Developer, Opera Software
Co-Chair, W3C SVG Working Group
Personal blog: http://my.opera.com/macdev_ed

Received on Tuesday, 15 July 2008 08:51:30 UTC