Re: Identity Constraints

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:unique>

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

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.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/

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