W3C home > Mailing lists > Public > public-html@w3.org > March 2008

Re: A use of SVG in HTML

From: Henri Sivonen <hsivonen@iki.fi>
Date: Sun, 16 Mar 2008 10:02:21 +0200
Cc: HTML WG <public-html@w3.org>
Message-Id: <C491E639-1BBE-4BC4-80D8-2281965D8414@iki.fi>
To: Philip Taylor <pjt47@cam.ac.uk>

On Mar 16, 2008, at 02:59, Philip Taylor wrote:

> The HTML response can contain multiple SVG graphs. Since they are  
> all generated independently by Graphviz, they all have a <g  
> id="graph0" ...> (plus lots of other common IDs). It would take far  
> too much effort to uniquify the IDs and fix up all the references  
> (particularly since the references can be in style="url(#...)" too).
> Currently I never use the IDs, so that doesn't matter, but this will  
> break if the SVG starts containing ID references (e.g. for <defs>)  
> or if I start using getElementById, so it would be good if this  
> overlapping ID situation could be handled well. (E.g. references  
> inside an <svg>-rooted subtree could preferentially match IDs in the  
> same subtree, before looking outside to the whole HTML document.)

I agree that this is a problem. The root of the problem is that the  
concept of IDs doesn't work with transclusions. However, it is a  
problem that cannot reasonably be solved by the parser and a problem  
that exists in XHTML+SVG and SVG+SVG as well. Rewriting IDs in the  
text/html parser won't work, since rewriting IDs in JavaScript that  
might refer to the IDs is not feasible. Therefore, I don't think  
solving this problem is in the same category as enabling SVG in text/ 
html in general.

Here's one way of solving this:
  * Removing the requirement for ID uniqueness in XML and HTML.
  * Making a change in parent vs. child element namespace establish a  
  * Making the presence of the xml:base attribute establish a scope.
  * Making ID matching take to arguments: the ID and a context node  
(i.e. moving gEBI on Node so that 'this' becomes the context node).
  * Making ID references prefer matches in the same scope moving up  
the scope tree if there is no match is the inner scope.

All in all, solving this problem would require some drastic changes.  
The problem may be too costly to solve. :-(

It seems to me that the least expensive fix is to change SVG  
generators to use GUID-style IDs to make the probability of an ID  
clash negligible.

Henri Sivonen
Received on Sunday, 16 March 2008 08:03:09 UTC

This archive was generated by hypermail 2.3.1 : Thursday, 29 October 2015 10:15:31 UTC