W3C home > Mailing lists > Public > whatwg@whatwg.org > June 2007

[whatwg] id and xml:id

From: Ian Hickson <ian@hixie.ch>
Date: Sat, 9 Jun 2007 02:25:47 +0000 (UTC)
Message-ID: <Pine.LNX.4.64.0706090218370.21984@dhalsim.dreamhost.com>
On Sun, 2 Apr 2006, Henri Sivonen wrote:
>
> Since UAs handle whitespace in the id attribute inconsistently (see 
> below)

Note that there is interoperability (in that, we have two browsers that do 
the same thing, and one of those is IE, even).


> old specs imply or require whitespace trimming

Old specs imply or require a lot of things. ;-)


> and ids with whitespace are unreferencable from whitespace-separated 
> lists of ids,

True.


> I suggest adding the following language concerning document conformance:
> 
> The value of the id attribute must be a string that consists of one or 
> more characters matching the following production: 
> [#x21-#xD7FF]|[#xE000-#xFFFD]|[#x10000-#x10FFFF] (any XML 1.0 character 
> excluding whitespace).

I've made it non-conforming for an ID to contain a whitespace character.


> Also, I suggest requiring that elements must not have both id and xml:id 
> and requiring that xml:id must not occur in the HTML serialization. 
> (Again, from the document conformance point of view--not disputing 
> requirements on browsers.)

I don't really want to mention xml:id. If someone wants to write a spec 
that affects our spec, that's their business. I don't think it makes sense 
for us to go ahead and then ban their spec. That's not to say that xml:id 
is good or bad, it just doesn't seem relevant to mention it in our spec.


> If an element had both an id attribute and an xml:id attribute with different
> values, the document would not be HTML-serializable, which would be bad.

That applies to any document that has nodes from other namespaces. xml:id 
isn't special in that sense.


> If an element was allowed to have an id attribute and an xml:id attribute with
> the same value, the following constraint from xml:id spec would be violated
> even for conforming docs:
> "An xml:id processor should assure that the following constraint holds:
>    * The values of all attributes of type ?ID? (which includes all xml:id
> attributes) within a document are unique."
> ( http://www.w3.org/TR/xml-id/ )

I don't really understand what you mean there.


> Finally, as the ultimate ID nitpicking, the spec should state that it is 
> naughty of authors to turn attributes other than id and xml:id into IDs 
> via the DTD. (Well, using a DTD at all is naughty. :-)

Again, if they want to do that, that's their business. I don't see that as 
a big problem.


> Test case: http://hsivonen.iki.fi/test/wa10/adhoc/id.html
> The script tries every id with a whitespaceless value to see if whitespace is
> trimmed before ID assignment.
>
> Safari and IE 6:
> 
> id='a' PASS
> id='2' PASS
> id='&lt;' PASS
> id=',' PASS
> id='&auml;' PASS
> id=' c ' FAIL
> id='\nd\n' FAIL
> id='\t\te\t\t' FAIL
> id='&#13;f&#13;' FAIL

That's what the spec requires today.

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'
Received on Friday, 8 June 2007 19:25:47 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:58:56 UTC