Document.getElementById() in XML documents

The DOM Level 2 spec has this to say about Document.getElementById():

"Note: The DOM implementation must have information that says which
attributes are of type ID. Attributes with the name "ID" are not of type
ID unless so defined. Implementations that do not know whether
attributes are of type ID or not are expected to return null."

I'm surprised by that last sentence, and I'd like to know whether that
is actually how things are implemented in practice.  Although I haven't
done it myself, I gather that the latest web browsers can display XML
documents when they've got an appropriate stylesheet.  I doubt that
those browsers are actually going out and parsing a DTD to determine the
type of each attribute, but I'd also really be surprised if they don't
just make getElementById() work with attributes named "ID".  In
practice, this seems like too important a method to break over a
technicality like this.

I'd be interested to hear from anyone who can comment on how this issue
is actually being handled in practice.

    David Flanagan

Received on Monday, 30 July 2001 01:10:54 UTC