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

Semantic of the unique/key/keyref constraints.

From: Eric van der Vlist <vdv@dyomedea.com>
Date: Mon, 18 Jun 2001 18:36:26 +0200
Message-ID: <3B2E2E0A.EBFA431C@dyomedea.com>
To: "xmlschema-dev@w3.org" <xmlschema-dev@w3.org>
Given the definition:

<xs:element name="foo">
 ...
 <xs:unique name="uniqueFoo">
   <xs:selector xpath="bar"/>
   <xs:field xpath="id"/>
 </xs:unique>
</xs:element>

my understanding of the rec is that this can be read in plain english as
"in each element foo, the sub elements bar identified by their id must
be unique".

In particular, the following paragraphs of part one: 

"{fields} specifies XPath expressions relative to each element selected
by a {selector}. This must identify a single node (element or attribute)
whose content or value, which must be of a simple type, is used in the
constraint. It is possible to specify an ordered list of {fields}s, to
cater to multi-field keys, keyrefs, and uniqueness constraints. "

and 

"For each node in the Ětarget node setĚ all of the {fields}, with that
node as the context node, evaluate to either an empty node-set or a
node-set with exactly one member, which must have a simple type."

let me think that each of the fields must identify a unique (or non
existing) node in the context of each occurrence of a selector.

If my interpretation is right, isn't it contrary to the example of
composed key given in the primer:

<unique name="dummy1">
 <selector xpath="r:regions/r:zip"/>
 <field    xpath="@code"/>
 <field    xpath="r:part/@number"/>
</unique>

where the field "r:part/@number" is pointing to 4 different nodes in
this case:

<regions>
 <zip code="95819">
  <part number="872-AA" quantity="1"/>
  <part number="926-AA" quantity="1"/>
  <part number="833-AA" quantity="1"/>
  <part number="455-BX" quantity="1"/>
 </zip>
...

Thanks to let me know what I have wrong (or to confirm my
understanding;) ) !

Eric  
-- 
Pour y voir plus clair dans la nebuleuse XML...
                                          http://dyomedea.com/formation/
------------------------------------------------------------------------
Eric van der Vlist       http://xmlfr.org            http://dyomedea.com
http://xsltunit.org      http://4xt.org           http://examplotron.org
------------------------------------------------------------------------
Received on Monday, 18 June 2001 12:36:31 GMT

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