Re: A use of SVG in HTML

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  
scope.
  * 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
hsivonen@iki.fi
http://hsivonen.iki.fi/

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