FIX: The Validation of Keys Does Not Work If You Define More Than One Key (316797)
The information in this article applies to:
- Microsoft XML Classes (included with the .NET Framework 1.0)
This article was previously published under Q316797 SYMPTOMS If you define multiple keys in the XML Schema Definition
(XSD) language schema file, as in the following example
<xsd:complexType name="JsmlDocumentType">
<xsd:sequence>
<xsd:element name="class" type="ClassType" minOccurs="1" maxOccurs="unbounded">
<xsd:key name="class-name-is-unique">
<xsd:selector xpath="class" />
<xsd:field xpath="@name" />
</xsd:key>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ClassType" mixed="false">
<xsd:sequence>
<xsd:element name="events" type="EventsType" minOccurs="0" maxOccurs="1">
<xsd:key name="event-name-is-unique">
<xsd:selector xpath="event" />
<xsd:field xpath="@name" />
</xsd:key>
</xsd:element>
...
</xsd:complexType>
you receive the following error message if you use the XmlValidatingReader class of the System.Xml namespace in .NET Framework to validate a XML file against the
XSD file: Exception Severity: Error There is a
duplicate key sequence 'InstanceCreated' for 'event-name-is-unique' key or
unique identity constraint. CAUSE This problem occurs if the Identity Constraints on elements
that are stored in the stack are not reset for later elements. RESOLUTION To work around this problem, move the element with the
constraints so that it appears last. STATUS This bug was corrected in Microsoft .NET Framework Class
Libraries 1.1.
Modification Type: | Major | Last Reviewed: | 9/24/2003 |
---|
Keywords: | kbbug kbpending KB316797 |
---|
|