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)

<?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:element name="entry" maxOccurs="unbounded">
            <xs:attribute name="key" use="required" type="xs:string"/>
    <xs:key name="entryKey">
      <xs:selector xpath="entry"/>
      <xs:field xpath="@key"/>

and the instance:
<swissprot xmlns="urn:org:expasy:models" 
xsi:schemaLocation="urn:org:expasy:models 1.xsd">
 <entry key="P30089"/>
 <entry key="P30089"/>

>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.

> 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"/>
> 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>
> ...
This should not work...


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

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:15:05 UTC