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

Re: Identity Constraints

From: Jeni Tennison <jeni@jenitennison.com>
Date: Fri, 8 Mar 2002 10:18:52 +0000
Message-ID: <21260961562.20020308101852@jenitennison.com>
To: Mark Thornton <mthornton@optrak.co.uk>
CC: "'xmlschema-dev@w3.org'" <xmlschema-dev@w3.org>
Hi Mark,

> The data I have looks like this:
> <table name='addresses'>
>         <column name='street'/>
>         <column name='town'/>
> </table>
> then elsewhere
> <table ref='addresses'>
>         <column ref='street'/>  <!-- refer to the street column defined
>                                      earlier -->
>         <column name='country'/> <!-- adds a new column to the 'addresses'
>                                       table -->
> </table>

I don't think it's possible to express that constraint with XML
Schema. Ideally you'd like to key the columns by a combination of
their parent table's name or ref, and their name, and then refer to
them in a similar way:

  <xs:unique name="kColumn">
    <xs:selector xpath="table/column" />
    <xs:field xpath="../@name|../@ref" />
    <xs:field xpath="@name" />

  <xs:keyref name="kColumnRef" refer="kColumn">
    <xs:selector xpath="table/column" />
    <xs:field xpath="../@ref" />
    <xs:field xpath="@ref" />

But the restrictions on the XPaths that are allowed within identity
constraints prevents you from doing that.

I think that Schematron would allow you to test this constraint;
Eddie's put together a great description of how to use it with XML
Schema at http://www.topologi.com/public/Schtrn_XSD/Paper.html.



Jeni Tennison
Received on Friday, 8 March 2002 05:18:53 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:55:55 UTC