W3C home > Mailing lists > Public > xmlschema-dev@w3.org > September 2002

Re: Question about uniqueness

From: Eddie Robertsson <erobertsson@allette.com.au>
Date: Wed, 11 Sep 2002 18:37:03 +1000
Message-ID: <3D7F00AF.3060100@allette.com.au>
To: Eric Jain <Eric.Jain@isb-sib.ch>
CC: xmlschema-dev@w3.org

Hi Eric,

Eric Jain wrote:

>>If your instance document use a default namespace and the element names
>>you use for uniqueness are qualified then the tools are wrong.
>>    
>>
Hmm, I just tested this with the following instance and schema 
(basically the same as you with the element declaration filled in)

1.xsd:
------
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
elementFormDefault="qualified" targetNamespace="urn:org:expasy:models">
  <xs:element name="swissprot">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="entry" maxOccurs="unbounded">
          <xs:complexType>
            <xs:attribute name="key" use="required" type="xs:string"/>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
    <xs:key name="entryKey">
      <xs:selector xpath="entry"/>
      <xs:field xpath="@key"/>
    </xs:key>
  </xs:element>
</xs:schema>

and the instance:
-----------------
<swissprot xmlns="urn:org:expasy:models" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="urn:org:expasy:models 1.xsd">
 <entry key="P30089"/>
 <entry key="P30089"/>
</swissprot>

>SQC, XSV, MSXML, Oracle, and Sun's MSV all agree that the following is
>valid, and complain if entryKey is duplicated:

Well, you can't check this constraint with SQC since identity 
constraints require an instance document.

XSV, MSXML, XML Spy4.4 all say that the above example is valid. This is 
correct since they can't find an unqualified entry element. What version 
of XSV and MSXML are you using to get them to complain about the 
duplicate key?
I don't have access to Oracle and MSV so I can't check with them.

If you add a namespace declaration to the schema 
(xmlns:t="urn:org:expasy:models") and then use this prefix in the XPath 
expression both XSV, MSXML and XML Spy pick up the duplicate key.

><swissprot
> xmlns="urn:org:expasy:models"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="urn:org:expasy:models swissprot.xsd"
>  
>
> <entry key="P30089"/>
> <entry key="P30090"/>
></swissprot>
>
>
><xsd:schema
> xmlns="urn:org:expasy:models"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> targetNamespace="urn:org:expasy:models"
> elementFormDefault="qualified"
>  
>
> ...
> <xsd:key name="entryKey">
>  <xsd:selector xpath="entry"/>
>  <xsd:field xpath="@key"/>
> </xsd:key>
> ...
></xsd:schema>
>
This should not work...

Cheers,
/Eddie

>
>
>--
>Eric Jain
>
>  
>
Received on Wednesday, 11 September 2002 04:37:16 GMT

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