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:keyref name="appleRefs" refer="appleNames">
  <xs:selector xpath="//apple[@ref]"/>
  <xs:field xpath="@ref"/>

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 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:14:54 UTC