W3C home > Mailing lists > Public > xmlschema-dev@w3.org > October 2005

Scope of keyref identity constraints (Xerces-J bug)

From: Kasimier Buchcik <K.Buchcik@4commerce.de>
Date: Tue, 11 Oct 2005 14:41:05 +0200
To: ML-xml-schema-dev <xmlschema-dev@w3.org>
Message-Id: <1129034465.1272.41.camel@librax>

Hi,

Xerces-J 2.7.1 reports for the following (brain-hurting) scenario:

keyref-2.xml:7,15: (Error) Identity Constraint error:  identity
constraint "KeyRef@1995d80" has a keyref which refers to a key or
unique that is out of scope.

... while XSV 2.10, IBM's SQC, Saxon 8.5.1, MSXML 4.0 SP2 and
Libxml2 2.6.22 report it as valid.

keyref-2.xsd
------------
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

  <xs:element name="SECTION-A" type="Section">
	<xs:key name="DefKey">
      <xs:selector xpath="DEFINITION"/>
      <xs:field xpath="."/>
    </xs:key>
  </xs:element>

  <xs:element name="SECTION-B" type="Section">  
    <xs:keyref name="DefRef" refer="DefKey">
      <xs:selector xpath="DEFREF"/>
      <xs:field xpath="."/>
    </xs:keyref>
  </xs:element>

  <xs:complexType name="Section">
    <xs:sequence>
	  <xs:element ref="SECTION-A" minOccurs="0"/>
	  <xs:element ref="SECTION-B" minOccurs="0"/>
	  <xs:element name="DEFINITION" type="xs:string" minOccurs="0"
maxOccurs="2"/>
	  <xs:element name="DEFREF" type="xs:string" minOccurs="0"
maxOccurs="5"/>
	</xs:sequence>
  </xs:complexType>

</xs:schema>

keyref-2.xml
------------

<SECTION-A xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:noNamespaceSchemaLocation="keyref-2.xsd">

  <SECTION-B>      
	  <DEFINITION>zappa</DEFINITION>
  </SECTION-B>
  <DEFREF>zappa</DEFREF>	

</SECTION-A>

Regards,

Kasimier
Received on Tuesday, 11 October 2005 12:41:20 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:51 GMT