Re: Constraint Specifications in XML Schemas

You can get close to what you need, but without chained keyrefs, which
we don't (yet) support, not all the way.

Add the following to get close:

1) to the elt decl for Database
 <xs:key name="table">
  <xs:selector xpath="Table"/>
  <xs:field xpath="@id"/>
 </xs:key>
 <xs:keyref name="foreign1" refer="table">
  <xs:selector xpath=".//ForeignTable"/>
  <xs:field xpath="@tableId"/>
 </xs:keyref>
 <xs:keyref name="foreign2" refer="field">
  <xs:selector xpath=".//ForeignField"/>
  <xs:field xpath="@fieldId"/>
 </xs:keyref>

2) to the elt decl for Table
 <xs:key name="field">
  <xs:selector xpath="Field"/>
  <xs:field xpath="@id"/>
 </xs:key>
 <xs:keyref name="local1" refer="field">
  <xs:selector xpath=".//KeyField"/>
  <xs:field xpath="@fieldId"/>
 </xs:keyref>
 <xs:keyref name="local2" refer="field">
  <xs:selector xpath=".//FieldRef"/>
  <xs:field xpath="@fieldId"/>
 </xs:keyref>
  
What's imperfect about this is that it doesn't check (because it
can't) that the foreign field is in the right foreign table.  The
real downside of this is that if their are two fields with the same
name in different tables, foreign key refs to them will be spuriously
identified as errors.

Hope this helps,

ht
-- 
  Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
          W3C Fellow 1999--2002, 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/
 [mail really from me _always_ has this .sig -- mail without it is forged spam]

Received on Friday, 1 November 2002 04:03:35 UTC