[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Another Schema Question
- From: Jeni Tennison <mail@jenitennison.com>
- To: "Bullard, Claude L (Len)" <clbullar@ingr.com>
- Date: Mon, 18 Jun 2001 13:01:56 +0100
Hi Len,
> So do fields specify a set of additional constraints or are these
> the complete constraint set? I am unclear as to the scope of the
> selector given that paragraph.
As I understand it, the fields specify the complete constraint set -
they point to the elements/attributes that give the values for the
key. The selector points to the elements that are indexed by the
fields. The position of the identity constraint (unique, key or
keyref) gives its scope.
It's easiest to see with examples - take the constraint "within each
Channel element, every Programme element must have a unique dateTime
attribute." The "within each X" indicates where the identity
constraint should go, in this case within the element declaration for
the Channel element:
<xs:element name="Channel">
<xs:complexType>
<xs:sequence><xs:element ref="Programme" /></xs:sequence>
</xs:complexType>
<xs:unique name="uniqueDateTime">
...
</xs:unique>
</xs:element>
The "every Y element" indicates what the selector should be. It's
specified relative to the element that's being declared:
<xs:element name="Channel">
...
<xs:unique name="uniqueDateTime">
<xs:selector xpath="Programme" />
...
</xs:unique>
</xs:element>
And the "should have a unique Z" indicates what the fields should
point to. They're specified relative to the unique elements:
<xs:element name="Channel">
...
<xs:unique name="uniqueDateTime">
<xs:selector xpath="Programme" />
<xs:field xpath="@dateTime" />
</xs:unique>
</xs:element>
If you specify several fields, then it's the combination of the fields
that must be unique rather than any one in particular. So if the date
and time for the Programme were held in separate attributes, then you
would have two fields:
<xs:element name="Channel">
...
<xs:unique name="uniqueDateTime">
<xs:selector xpath="Programme" />
<xs:field xpath="@date" />
<xs:field xpath="@time" />
</xs:unique>
</xs:element>
Cheers,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/