Re: "Intelligent" element and attribute creation

Steve Schafer wrote:
> It would be nice to be able to do the same thing with attribute objects,
> but we're hampered in two respects:
> 
> 1) Most attributes don't have associated namespaces, so we can't figure
> out what an attribute whose name is "x," for example, is supposed to
> mean. In other words, we don't have sufficient context in which to
> create an appropriate "intelligent" attribute.
> 
> 2) Even if our attribute does have an associated namespace, it turns out
> that that still doesn't give us enough context. Within a single
> namespace, there are cases where a single attribute name has different
> interpretations depending on the element in which the attribute is
> embedded. Once again using SVG as an example, the value of a "rotate"
> attribute applied to the <tspan> element has different semantics, and
> even different syntax, from a "rotate" attribute applied to the
> <animateMotion> element.
> 
> Of course, such an intelligent attribute wouldn't support any additional
> interfaces beyond Attr, but from an implementation point of view it
> would be a Very Good Thing to be able to encapsulate an attribute's
> semantics (and syntax) within the attribute object itself.

I understand your wishes but can that not be solved differently by the 
implementation? Also, you are skipping over the fact that the exact same problem 
exists for elements. For example, when instatiating an HTMLLIElement the value 
field only has meaning when the <li> is contained in a <ul>, but not in a <ol>. 
An implementation might want to somehow deal with that at creation time, but it 
can't: it has to wait for the moment when the element is added to its parent.

The same goes for attributes. I'm not saying that your problem doesn't exist, 
simply that it seems to me to be impossible to solve in a generic way (which is 
what the DOM ought to do). You propose to give element (name) context but is 
that context enough? It could depend on the ancestry of said element.

In the case of SVG, I believe all that you raise goes away when using 
setAttributeNS() (that might not be true in other languages). And if users use 
the createAttributeNS() approach (which I've very rarely seen), can't you 
specialise your attribute when it's added to an element? I understand that not 
all languages can change the type of an object at runtime, but surely there's an 
implementation solution to this (eg speciliaze a given internal field).

> [ASIDE: All of my numerous attempts to subscribe to the www-dom mailing
> list have failed miserably. I don't get any kind of acknowledgment;
> nothing happens whatsoever. I can subscribe to the other W3C mailing
> lists just fine, so I have no idea what the problem is. What am I
> missing?]

If you get this twice, you're subscribed.

-- 
Robin Berjon <robin.berjon@expway.fr>
Research Scientist, Expway      http://expway.com/
7FC0 6F5F D864 EFB8 08CE  8E74 58E6 D5DB 4889 2488

Received on Sunday, 5 October 2003 14:27:43 UTC