W3C home > Mailing lists > Public > public-xml-id@w3.org > February 2005

Re: Multiple ID attributes on a single element

From: Anne van Kesteren <fora@annevankesteren.nl>
Date: Mon, 07 Feb 2005 21:01:31 +0100
Message-ID: <4207C91B.4030003@annevankesteren.nl>
To: Norman Walsh <Norman.Walsh@Sun.COM>
CC: veillard@redhat.com, public-xml-id@w3.org

> | # <p xmlns="http://www.w3.org/1999/xhtml" id="foo" xml:id="bar"/>
> |
> | Which ID attribute is considered to be the ID attribute of the
> | element? (What is the value of the ID attribute of this element when
> | I request it.) Or can a well-formed XML document have multiple ID
> | attributes per element albeit invalid XML?
> 
> The value of the ID attribute when you request it is going to depend
> on which one you request :-). You can't have a schema (small 's') that
> defines both id and xml:id as having type ID. I think there are several
> cases to consider:
> 
> 1. There's no schema. In that case, the ID of this element is 'bar'
>    because 'id' is not an ID.
> 
> 2. There's a schema that defines xml:id as an ID. In that case, the ID
>    of this element is 'bar' because 'id' is not an ID.
> 
> 3. There's a schema that defines id as an ID (but does not declare
>    xml:id). In that case, the ID of this element is...both foo and bar
>    is the best answer I can give.
> 
> 4. There's no schema, but the application gives attributes named id
>    special significance anyway. In that case, the ID of this element
>    is...both foo and bar is the best answer I can give.
> 
> In both case 3 and case 4, the application still has some freedom to
> decide what the right answer is. In resolving other last call
> comments, we've explicitly made the point that xml:id is about
> determing what things are IDs, not about saying what applications do
> with them or how they might additionally be constrained.

That is too bad. It would be nice if the specification stated that 
xml:id should be considered more important when two elements are of type ID.


> With respect to having multiple ID values on a single element, it's
> already possible in W3C XML Schema (because XSD allows both attributes
> and elements to have the type 'ID' and makes no prohibition against
> multiple elements of type ID or against an element having both an
> attribute and a child of type ID).

Perhaps a future version of XSD should say that the only way to create 
an XML ID is by using xml:id? That would remove the "element can be an 
ID" cruft and removes option 3 you mentioned.


> On a more philosophical level, I have never found anyone who could
> provide a good reason why the prohibition against multiple ID
> attributes exists in SGML. (It exists in XML only because it existed
> in SGML.)

Perhaps because an ID has to be unique for the document and it does not 
really make sense to make the element unique twice or more times?


> I hope that xml:id doesn't introduce a whole slew of nasty issues
> around elements with multiple ids. I hope, instead, that the world
> will migrate towards using xml:id exclusively. Certainly in
> applications that require validity, the presence of both id and xml:id
> can be prevented.

That would certainly be useful. And possible if some new XSD version 
would adopt the proposal above.


-- 
  Anne van Kesteren
  <http://annevankesteren.nl/>
Received on Monday, 7 February 2005 20:02:05 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 19:53:49 UTC