W3C home > Mailing lists > Public > www-tag@w3.org > January 2003

Re: Options for dealing with IDs

From: Chris Lilley <chris@w3.org>
Date: Fri, 10 Jan 2003 18:56:11 +0100
Message-ID: <2319355671.20030110185611@w3.org>
To: Jeni Tennison <jeni@jenitennison.com>
CC: www-tag@w3.org

On Friday, January 10, 2003, 6:17:19 PM, Jeni wrote:

JT> Hi Chris,

>> JT>   <foo xml:idAttr="id">
>> JT>     <bar id="fred" />
>> JT>     <baz xml:idAttr="ID" ID="barney" />
>> JT>   </foo>
>> JT> As I understand it, if <baz> had an id attribute then that would also
>> JT> be counted as an ID. Is that correct, or is your intention that there
>> JT> is only ever be one attribute in scope as an ID attribute at any one
>> JT> time?
>> The latter. I imagined that only one attribute of type ID could be
>> in scope on an element at a given time. I should revise the
>> description to make it clearer.

JT> Right. I think that this makes situations where you have repeated
JT> nested snippets from multiple namespaces, e.g.:

JT>   <doc xml:idAttr="id">
JT>     <rdf:RDF xml:idAttr="ID">
JT>       ...
JT>       <html:p xml:idAttr="id">
JT>         ...
JT>       </html:p>
JT>       ...
JT>       <html:p xml:idAttr="id">
JT>         ...
JT>       </html:p>
JT>       ...
JT>     </rdf:RDF>
JT>     ...
JT>   </doc>

JT> really tedious to deal with.

Yes, it does. That is a drawback, though not necessarily a showstopper
(I can se though that particularly where you know that the set of
namespaces has disjoint names for its id s and there are no falso
positives 0- as for the xhtml/RDF casse - your "list on the root"
suggestion makes things easier.)

A similar situation arises with namespace declarations
and is dealt with by avoiding defaulting the namespace and using
namespace prefixes throughout (as you ave done above) and declaring all
the namespaces once in a list.

Its possible that a similar mechanism to xmlns could be deployed (but
its a bit messy)

xmlidAttr:html="id" xmlidAttr:rdf="ID"

It would however save a bunch of typing in the highly interleaved
>> JT> xml:idAttrs would allow multiple attributes to be labelled as ID
>> JT> attributes; in this example you could do:
>> JT>   <foo xml:idAttrs="id ID">
>> JT>     <bar id="fred" />
>> JT>     <baz ID="barney" />
>> JT>   </foo>
>> Uh okay but lets now say that we have a namespace toto where id is
>> an ID attribute and partnum is CDATA; and another namespace tata
>> where partnum is an ID and id is CDATA. With your proposal I would
>> be unable to describe the multi-namespace document

JT> Note that I did say that xml:idAttrs was scoped (i.e. like option #6
JT> rather than option #5, though you could include a version like option
JT> #5 if you wanted) -- it doesn't *have* to appear on the document
JT> element. In this situation you could use:

JT> <?xml version="1.0" encoding="UTF-8"?>
JT> <foo>
JT>   <toto xml:idAttrs="id" id="zeus" partnum="a54321"
JT>         xmlns="http://toto"/>
JT>   <tata xml:idAttrs="partnum" id="hera" partnum="x12345"
JT>         xmlns="http://tata"/>
JT> </foo>

OK so in that case it becomes the same as option 6 in fact, but in
cases where the names of all the ID attributes in all namespaces are
known in advance and it is known that there are no inadvertent
clashes, the list form would be used and xml:idAttr would only be used
on subtrees for disambiguation purposes.

JT> If you wanted you could use it in just the same way as xml:idAttr, but
JT> you could also use it higher up if that was more convenient and it
JT> didn't cause clashes. It's a superset of the functionality of
JT> xml:idAttr.

Yes, I can see that now I realize that your proposal was scoped as

 Chris                            mailto:chris@w3.org
Received on Friday, 10 January 2003 12:56:37 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:55:56 UTC