W3C home > Mailing lists > Public > xmlschema-dev@w3.org > October 2001

Re: Identity Constraints

From: Curt Arnold <curta@houston.rr.com>
Date: Mon, 22 Oct 2001 18:30:37 -0400 (EDT)
Message-ID: <004a01c15b48$dec83440$7600a8c0@CurtMicron>
To: "Robyn Dean" <rdean@fourbit.com>
Cc: <xmlschema-dev@w3.org>
From: "Robyn Dean" <rdean@fourbit.com> wrote:

> I would like the instance document to look like:
> <FruitSalad>
> <apple ref="Granny"/>
> <apple canEatSkin="true" color="yellow" makesGoodPie="false"/>
> <banana canEatSkin="false"/>
> </FruitSalad>
> <apple name="Granny" color="green" canEatSkin="true" makesGoodPie="true"/>
> <apple name="SnowWhite's" color="red" canEatSkin="false"
> makesGoodPie="false"/>

Well, that wouldn't be a valid XML document since there are multiple top
level elements.  You can used xs:key and xs:keyref to perform that type of
validation, however they are defined on the containing element.  If you
wrapped everything in a <RecipeBook> element and then added something like:

<xs:element name="RecipeBook">
...
<xs:key name="appleNames">
  <xs:selector xpath="apple"/>
  <xs:field xpath="@name"/>
</xs:key>
<xs:keyref name="appleRefs" refer="appleNames">
  <xs:selector xpath="//apple[@ref]"/>
  <xs:field xpath="@ref"/>
</xs:keyref>

Look at the primer for more examples.  Not sure if the [@ref] is legal or
necessary.  Should give you enough to review the docs.
Received on Tuesday, 23 October 2001 04:10:06 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:24 GMT