This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 3968 - Elements with duplicate IDs
Summary: Elements with duplicate IDs
Status: CLOSED WORKSFORME
Alias: None
Product: XML Schema
Classification: Unclassified
Component: Structures: XSD Part 1 (show other bugs)
Version: 1.0/1.1 both
Hardware: All All
: P2 normal
Target Milestone: ---
Assignee: C. M. Sperberg-McQueen
QA Contact: XML Schema comments list
URL:
Whiteboard:
Keywords: resolved
Depends on:
Blocks:
 
Reported: 2006-11-10 02:38 UTC by Sandy Gao
Modified: 2007-04-13 16:55 UTC (History)
0 users

See Also:


Attachments
Test case: schema (256 bytes, text/xml)
2007-01-15 21:27 UTC, Sandy Gao
Details
Test case: instance (157 bytes, text/xml)
2007-01-15 21:27 UTC, Sandy Gao
Details
Test case 2: schema (256 bytes, text/xml)
2007-01-15 21:59 UTC, Sandy Gao
Details
Test case 2: instance (155 bytes, text/xml)
2007-01-15 21:59 UTC, Sandy Gao
Details
Test case 3: schema document (285 bytes, text/xml)
2007-02-13 22:58 UTC, C. M. Sperberg-McQueen
Details
Test case 3: XML instance (162 bytes, text/xml)
2007-02-13 23:00 UTC, C. M. Sperberg-McQueen
Details
Test case 4: schema document (281 bytes, text/xml)
2007-02-28 14:43 UTC, Sandy Gao
Details
Test case 4: XML instance (143 bytes, text/html)
2007-02-28 14:44 UTC, Sandy Gao
Details

Description Sandy Gao 2006-11-10 02:38:38 UTC
Consider an element declaration
<element name="e">
  <complexType>
    <sequence>
      <element name="id1" type="ID"/>
      <element name="id2" type="ID"/>
    </sequence>
  </complexType>
</element>

And the instance
<e><id1>abc</id1><id2>abc</id2></e>

Many people would think the above is invalid, because there are duplicate ID values. But a careful reading of the "ID/IDREF Table" PSVI property suggests that the above is valid. There will only be one entry in the [binding], the element "e".

Is this intended? Is this how most schema processors implemented ID/IDREF? Either way, some clarification will be helpful.
Comment 1 Henry S. Thompson 2006-11-10 09:31:29 UTC
No harm, no foul.  The guarantee ID provides is that no ID is attached to two distinct items.  In SGML and XML, there was also a declaration constraint which prevented items from having two IDs, but we explicitly did _not_ reconstruct this constraint except for attributes, although both parts 1 and 2 both suggest not using ID for the type of elements.

The example schema given makes it possible for an element to have multiple IDs, but then the instance doesn't exploit this.  In my view the resulting ID/IDREF table is correct -- one entry, with one binding, i.e. 'abc' bound to the doc. element.

And I think the spec. correctly specifies that in case of an instance such as

 <e><id1>abc</id1><id2>xyz</id2></e>

there will be _two_ entries in the ID/IDREF table, one binding 'abc' to the doc. elt and one binding 'xyz' to it.  Your gun, your foot, your bullet.

In other words, no bug, no change required.
Comment 2 Sandy Gao 2007-01-15 21:27:13 UTC
Created attachment 446 [details]
Test case: schema
Comment 3 Sandy Gao 2007-01-15 21:27:43 UTC
Created attachment 447 [details]
Test case: instance
Comment 4 Sandy Gao 2007-01-15 21:59:14 UTC
Created attachment 448 [details]
Test case 2: schema
Comment 5 Sandy Gao 2007-01-15 21:59:35 UTC
Created attachment 449 [details]
Test case 2: instance
Comment 6 C. M. Sperberg-McQueen 2007-02-13 22:58:42 UTC
Created attachment 453 [details]
Test case 3: schema document

One ID attribute, two ID (sub-)elements.
Comment 7 C. M. Sperberg-McQueen 2007-02-13 23:00:39 UTC
Created attachment 454 [details]
Test case 3: XML instance

Three dependents of type ID with different values, all
on the same element.  Several people have said all processors
will behave the same on this, but some thing that
all processors will accept it, others that all will
reject it.

The spec is I think clear that the schema is OK and
the instance is valid against the schema.
Comment 8 Sandy Gao 2007-02-28 14:43:56 UTC
Created attachment 458 [details]
Test case 4: schema document

When an element's simple content is of type ID and one of its attributes also has type ID, test whether the 2 IDs can have the same value.
Comment 9 Sandy Gao 2007-02-28 14:44:55 UTC
Created attachment 459 [details]
Test case 4: XML instance

When an element's simple content is of type ID and one of its attributes also has type ID, test whether the 2 IDs can have the same value.
Comment 10 Sandy Gao 2007-04-13 16:55:02 UTC
The working group discussed this issue at the 2007-03 F2F meeting. It was observed that
- Users and some specifications, as with schema itself, view elements with IDs as identifying their parents
- Users may want to use different ways (sub-elements/attributes) to identify the same element, but using the same ID value.

Based on these, the WG decided not to change the behavior in the current schema spec.