W3C home > Mailing lists > Public > public-html@w3.org > August 2007

Re: ID Characters (was: Re: 3.4. Global attributes)

From: Robert Burns <rob@robburns.com>
Date: Wed, 1 Aug 2007 10:18:42 -0500
Message-Id: <6023614D-A60F-4570-ACFB-08182DFFBE73@robburns.com>
To: HTML WG <public-html@w3.org>

On the issue of the @id attribute and compatibility, I'm not sure  
what we're trying to accomplish here. Henri says[1] that the  
attribute is of type CDATA and not of type ID

The current draft[2][3] says:

"The value must be unique in the subtree within which the element  
finds itself and must contain at least one character."

I'm not sure I understand what this means, but it sounds to me like  
@id attributes need only be unique within a particular node (or  
within a depth traversal of a node)? Again, I don't really understand  
what the current draft means by that. I had earlier mentioned the  
idea of having a new attribute like a @pathid or @nodeid attribute  
where uniqueness would only be guaranteed on the same hierarchical  
level (similar to the way uniqueness is required in a hierarchical  
file system). Such an attribute would allow easy traversal through  
XPath or XPoitner type expressions and would avoid attribute value  
collisions in combining documents. Is this what HTML5 is doing with  
@id? If so, does that work with compatibility?

 From HTML4[4] the @id attribute has to be unique throughout an  
entire document and the attribute takes a value of type ID[5]. In XML  
the @id attribute must be unique in the document, there must only be  
one ID per element[6].

The current draft also says[2][3]:

"This specification doesn't preclude an element having multiple IDs,  
if other mechanisms (e.g. DOM Core methods) can set an element's ID  
in a way that doesn't conflict with the id attribute."

Again, I don't really understand what this paragraph is saying. Is  
this multiple attributes with different names all taking a value of  
type ID? or is this one @id attribute with multiple whitespace or  
comma delimited values? Or is this just multiple values of @id or  
multiple type IDs within the DOM?

Also, what are the use-cases this is trying to address. Why would we  
need to have multiple @id attributes on the same element? I can  
understand this node-unique ID, but it's hard to decipher what  
multiple IDs on the same element would be used for?

Again, this would seem to break compatibility with XML that requires  
only a single ID on each element.

The concerns I'm raising here pertain to document conformance and not  
to UA conformance. Obviously UAs can be as lenient as possible on  
this. However, what are we gaining by encouraging authors to use id  
values that could cause problems down the road. In some sense I think  
we want IDs to be as persistent as possible because ever time IDs  
have to change they run the risk of breaking things (hence the idea  
of a node-unique id). So this suggests to me that we should stick  
with the HTML4 and XML notion of an ID. If we want to add another  
unique identifier it could have a different name (such as @key).

I don't think this really is related to DTD or RelaxNG or XSD, etc.  
However, I look at the HTML4 recommendation and the XML 1  
recommendation and we do not appear to fit in with respect to ID.  
That doesn't sound like a good thing (in terms of document conformance).

Take care,
Rob

[1]: <http://lists.w3.org/Archives/Public/public-html/2007Aug/0018.html>
[2]: <http://dev.w3.org/cvsweb/~checkout~/html5/spec/Overview.html? 
rev=1.78#the-id>
[3]: Complete id text in current draft:
"The id attribute represents its element's unique identifier. The  
value must be unique in the subtree within which the element finds  
itself and must contain at least one character.
If the value is not the empty string, user agents must associate the  
element with the given value (exactly) for the purposes of ID  
matching within the subtree the element finds itself (e.g. for  
selectors in CSS or for the getElementById() method in the DOM).
Identifiers are opaque strings. Particular meanings should not be  
derived from the value of the id attribute.
This specification doesn't preclude an element having multiple IDs,  
if other mechanisms (e.g. DOM Core methods) can set an element's ID  
in a way that doesn't conflict with the id attribute.
The id DOM attribute must reflect the id content attribute."
[4]: <http://www.w3.org/TR/html4/struct/global.html#adef-id>
[5]: <http://www.w3.org/TR/html4/types.html#type-id>
[6]: <http://www.w3.org/TR/xml/#sec-entexpand>
Received on Wednesday, 1 August 2007 15:18:57 UTC

This archive was generated by hypermail 2.3.1 : Monday, 29 September 2014 09:38:47 UTC