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

Re: key/keyref problem

From: Eric van der Vlist <vdv@dyomedea.com>
Date: Mon, 02 Jul 2001 22:00:50 +0200
Message-ID: <3B40D2F2.F545B80D@dyomedea.com>
To: priscilla@walmsley.com
Cc: "'WATKIN-JONES,ADAM (HP-UnitedKingdom,ex1)'" <adam_watkin-jones@hp.com>, xmlschema-dev@w3.org
Priscilla Walmsley wrote:
> Hello,
> You are correct that it should be a QName.  I suspect it was a bug in a
> previous version of XSV because the current on-line version of XSV does not
> consider it an error.

Good ;) ...

> To answer your question about why it is a QName, the key and keyref
> definitions do _not_ have to be defined side by side in the same scoping
> element.  The scoping element of the key can be a child of the scoping
> element of the keyref.  That child may be in a different namespace.

This is a point I find most confusing in the spec.

The rec [1] says that:

If the {identity-constraint category} is keyref, then for each member of
the ·qualified node set· (call this the keyref member), there must be a
·node table· associated with the {referenced key} in the
[identity-constraint table] of the element information item (see
Identity-constraint Table (§3.11.5), which must be understood as
logically prior to this clause of this constraint, below) and there must
be an entry in that table whose ·key-sequence· is equal to the keyref
member's ·key-sequence· member for member, as defined by Equal in [XML
Schemas: Datatypes].


I am probably wrong, but I read this as implying a need that the key and
keyref tables belong to the same element.

Furthermore, I would also think that allowing scoping element of the key
or unique definition to be a child of the scoping element of the keyref
still more confusing.

If I understand what you mean correctly, it's allowing cases such as:

   <key id="1"/>
   <key id="2"/>
   <key id="2"/>
   <key id="3"/>
 <keyref ref="2"/>


<xs:element name="root">

  <xs:element name="sub">
   <xs:key name="key">
    <xs:selector xpath="key"/>
    <xs:field xpath="@id"/>

  <xs:keyref name="keyref" refer="key">
   <xs:selector xpath="keyref"/>
   <xs:field xpath="@ref"/>


where one cannot determine which key is referred by a keyref.

This is also troubling to see that the scope of a key is wider than the
element in which it is defined and I would have found it less confusing
if it would have been the scoping element of the keyref that could have
been a child of the scoping element of the key or unique.

I have probably misread the rec and|or your answer, but I can't figure
out what I have wrong!

> In this example, mykey could have been defined in the declaration of keys,
> and dummy1 could have been defined in the declaration of root.
> Hope that helps!

Yes, it does.


> Priscilla Walmsley
> Vitria Technology
See you at XTech in San Diego.
Eric van der Vlist       http://xmlfr.org            http://dyomedea.com
http://xsltunit.org      http://4xt.org           http://examplotron.org
Received on Monday, 2 July 2001 16:01:05 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:55:52 UTC