Right. I'm more on the XHTML side of things, but I do some XML parsing too (SAX mostly). It seems to me that if you're depending on elements having an "id" attribute in XML-land, then you're doing something wrong. The "id" attribute is very HTML-specific. The interface for an XML document shouldn't even have a getElementById() method, in my opinion. The XHTMLDocument interface (or whatever it's called) should extend XMLDocument and HTMLDocument, thereby acquiring getElementById() from the latter.
It seems like it wouldn't be too difficult for XHTMLElementImpl.cloneNode() and XHTMLElementImpl.importNode() to access its XHTMLDocument's id map. The implementations of these methods in XMLElementImpl wouldn't care about maintaining maps of any attributes.
It all seems pretty straightforward to me, but I'm no expert in XML parsing or DTDs, so I'm sure there are more complicated issues that I'm missing. I'd be against a standard "xml:id" attribute.
just my $0.02, ErikOn Jan 26, 2007, at 3:08 AM, Jacob Kjome wrote: Keep in mind that the discussion here is XML-centric. Because there is no inherent "id" attribute in XML (people have proposed a standard "xml:id" attribute), there is no fallback like there is in the HTML DOM, where it can simply recurse the DOM for elements with the "id" attribute and see if they match the desired value. I like what Elliotte Rusty Harold had to say about it and agree that the ID'ness of attributes should be carried over. And it sounds like it's simply an issue with the cloneNode(). Which might make sense if the original implementors of cloneNode() decided that if they cloned ID'ness and someone cloned a node with an attribute of type "ID", then there's be duplicate ID's, creating an invalid DOM. However, there's lots of ways for a user to mess up a DOM and make it invalid. What's one more, especially when user's are likely to know what they are doing and avoid doing bad things.
But again, that's just my opinion as an end-user outside the DOM black box. I'm pretty sure that _javascript_ DOM behaves the way I've described. But then _javascript_ is out there in Anything Goes Land without DTDs to respect.
The javascipt DOM is HTML-centric and treats "id" attributes as of type "ID". You said it yourself. There's no "DTDs to respect". As such, it must make assumptions about what is an Id. They simply don't have to face the issues that Xerces (or any parser) has with XML. HTML is easy.
|