Possible issue: uniqueness of IDs

The following is adapted from a response I just gave on SOAP builders:

Graham Glass asks:
>> My understanding is that id attributes should be unique within an
>> XML document.

>> My question is: what is the scope of this convention? For example,
>> can a SOAP header have an element with id='1' and a SOAP body
>> also have an element with id='1'?

My reading of XML 1.0 is that the limitation applies across the entire
envelope, but only if you choose to use a DTD that types the attributes as
being of type ID. See: [1].  It's a validity constraint, not a
well-formedness requirement.  If you're not using a DTD, I don't believe
that ID= attributes need to be
unique at all.

Now, that's all true in the absence of the chapter 5 SOAP encoding.  If you
do use the encoding, then we find in [2]:

"A multi-reference simple or compound value is encoded as an independent
element containing a local, unqualified attribute named "id" and of type
"ID" per the XML Specification"

which makes clear that even though SOAP does not in general use DTDs, such
attributes are considered to be of type ID when they occur in an encoded
SOAP data graph (I.e. chapter 5 of SOAP 1.1), and in that case must be
unique across the entire document, not just the graph!  I suspect there is
a hole in the spec regarding the case where we have in the same envelope:

        <E1 ID="ONE" />
        <E2 ID="ONE"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />

E2 clearly carries an ID that has to be unique.  I think E1 is ambiguous,
depending on whether someone is using a DTD that explicitly types E1/ID as
being of type ID.

Possile XML Protocols issue that should be openned:  are we sufficiently
clear on the rules for attributes of type ID and for attributes named ID=?
In cases where encoding is used?  When it's not used?  When some parts of
the document are encoded and some not?  What do we say about the possible
use of external DTDs or schemas to process such messages and type such
attributes?

[1] http://www.w3.org/TR/REC-xml#sec-attribute-types
[2] http://www.w3.org/TR/SOAP/#_Toc478383513

------------------------------------------------------------------------
Noah Mendelsohn                                    Voice: 1-617-693-4036
Lotus Development Corp.                            Fax: 1-617-693-8676
One Rogers Street
Cambridge, MA 02142
------------------------------------------------------------------------

Received on Friday, 30 November 2001 14:08:46 UTC