OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Identity-constraint



Eddie Robertsson <eddie@allette.com.au> writes:

> I don't think that XSV has fully implemented the validation regarding keys
> and keyref yet but I don't think that is the problem with your
> schema.

Correct on both counts.  XSV is not complete in this area, but it _is_ 
complete enough to catch bugs in the case at hand.

> From what I can understand of your instance above you want to define
> a key for Item1/@Item1_2 and then reference this key saying that the
> value of Item2/@Item2_2 must be the same as an already existing
> Item1/@Item1_2.  Correct?  If this is correct you must declare the
> key in the scope of where you want it to be unique and in this case
> you want the Item1/@Item1_2 value to be unique within the scope of
> the Project element. This means that the key should be declared
> within the scope of the Project element and not within the scope of
> the Item1 element. The same will apply to your keyref declaration,
> it should be declared within the scope of the Project element
> instead of the Item2 element. This means your schema should be:

Correct analysis.  Schema _slightly_ buggy -- remember XPath does not
utilise the default namespace declaration.

> <?xml version="1.0" encoding="UTF-8"?>
> <xsd:schema xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"
> elementFormDefault="qualified" targetNamespace="www.allette.com.au/keyref"
> xmlns="www.allette.com.au/keyref">

  xmlns="www.allette.com.au/keyref" xmlns:r="www.allette.com.au/keyref">

>  <xsd:element name="Project">
>   <xsd:complexType>
>    <xsd:sequence>
>     <xsd:element ref="Item1" minOccurs="0"/>
>     <xsd:element ref="Item2" minOccurs="0"/>
>    </xsd:sequence>
>   </xsd:complexType>
>   <xsd:key name="Item1Key">
>    <xsd:selector xpath="Item1"/>

     <xsd:selector xpath="r:Item1"/>

>    <xsd:field xpath="@Item1_2"/>
>   </xsd:key>
>   <xsd:keyref name="Item2_KeyRef" refer="Item1Key">
>    <xsd:selector xpath ="Item2"/>

     <xsd:selector xpath ="r:Item2"/>

>    <xsd:field xpath ="@Item2_2"/>
>   </xsd:keyref>
>  </xsd:element>

With these changes this validates the example and catches errors if
you add them.

ht
-- 
  Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
          W3C Fellow 1999--2001, part-time member of W3C Team
     2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
	    Fax: (44) 131 650-4587, e-mail: ht@cogsci.ed.ac.uk
		     URL: http://www.ltg.ed.ac.uk/~ht/