Hi, I need your opinion whether this is conformant to the XML schema specification or not (or left to the implementation). Just being curious.
By mistake, I created a schema with a key and keyref where one attribute is of type xs:string and the other has no type (i.e. has xs:anySimpleType). Different parsers return different results: Altova XMLSpy: ok Xerces 2.7.0, 2.8.0, 3.0.1, 3.1.0 and 3.1.1: NOT ok MS XML 4 SP3: ok MS XML 6: NOT ok .NET 2.0: ok Java 1.6u23 org.xml.sax: NOT ok Here is a small example schema: <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="Main"> <xs:complexType> <xs:sequence> <xs:element name="FirstPath" type="FirstPathT"/> <xs:element name="SecondPath" type="SecondPathT"/> </xs:sequence> </xs:complexType> <xs:key name="FirstElement_SomeID"> <xs:selector xpath=".//FirstElement"/> <xs:field xpath="@SomeID"/> </xs:key> <xs:keyref name="SecondElement_SomeRef" refer="FirstElement_SomeID"> <xs:selector xpath=".//SecondElement"/> <xs:field xpath="@SomeRef"/> </xs:keyref> </xs:element> <xs:complexType name="FirstPathT"> <xs:sequence> <xs:element name="FirstElement" type="FirstElementT" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> <xs:complexType name="SecondPathT"> <xs:sequence> <xs:element name="SecondElement" type="SecondElementT" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> <xs:complexType name="FirstElementT"> <xs:attribute name="SomeID" type="xs:string" use="required"/> </xs:complexType> <xs:complexType name="SecondElementT"> <xs:attribute name="SomeRef" use="required"/> </xs:complexType> </xs:schema> And here the instance: <?xml version="1.0" encoding="UTF-8"?> <Main xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="test.xsd"> <FirstPath> <FirstElement SomeID="153938"/> </FirstPath> <SecondPath> <SecondElement SomeRef="153938"/> </SecondPath> </Main> FirstElement/@SomeId is of type xs:string and SecondElement/@SomeRef has no type, but the result is the same when FirstElement/@SomeId has no type and SecondElement/@SomeRef is of type xs:string. Error at file test.xml, line 9, char 8 Message: identity constraint key for element 'Main' not found Thanks in advance. With best regards, Herbert Oppmann Siemens AG Industry Sector Industry Automation Division Industrial Automation Systems Research & Development I IA AS R&D DH NBG 3 Gleiwitzer Str. 555 90475 Nuremberg, Germany Tel.: +49 (911) 895-2657 Fax: +49 (911) 895-152657 mailto:[email protected] Siemens Aktiengesellschaft: Chairman of the Supervisory Board: Gerhard Cromme; Managing Board: Peter Loescher, Chairman, President and Chief Executive Officer; Wolfgang Dehen, Brigitte Ederer, Joe Kaeser, Barbara Kux, Hermann Requardt, Siegfried Russwurm, Peter Y. Solmssen; Registered offices: Berlin and Munich, Germany; Commercial registries: Berlin Charlottenburg, HRB 12300, Munich, HRB 6684; WEEE-Reg.-No. DE 23691322
