W3C home > Mailing lists > Public > www-xml-schema-comments@w3.org > April to June 2001

potential erratum in XML Schema Primer

From: <neilg@ca.ibm.com>
Date: Fri, 22 Jun 2001 17:43:55 -0400
To: www-xml-schema-comments@w3.org
Message-ID: <OF39EAD0F9.3DAF277A-ON85256A73.00745044@torolab.ibm.com>

From 3.11.4 of the Schema Structures specification we have:

Validation Rule: Identity-constraint Satisfied

4.3 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
is equal to the keyref member's
member for member, as defined by
[XML Schemas: Datatypes].

In lay terms, I take this to mean that:

1.  For all sequences of strings identified by the fields of a <keyref>,
there must exist a sequence of pairwise equal strings identified by the
identity constraint that the <keyref> references;

2. Let element K be an element in the instance document which is validated
by a schema declaration which contains a <keyref>.  Now consider the set of
nodes S  identified by applying the xpath descendant-or-self axis to K.
Then one of the nodes in S must be validated by an element declaration
containing an identity constraint which the "refer" attribute of the
<keyref> resolves to.  That is to say, the identity constraint referenced
by the <keyref> must apply to the element the <keyref> is on or to one of
its descendants in a given instance document.

If the above is correct, then the following example from the beginning of
chapter 5 of the Schema Primer cannot be valid, because in any instance
document validated by this schema, the element containing the <keyref> must
occur as a descendant of the element containing the identity constraint to
which the <keyref> occurs.

<element name="purchaseReport">
               <element name="regions" type="r:RegionsType">
                    <keyref name="dummy2" refer="r:pNumKey">
                         <selector xpath="r:zip/r:part"/>
                         <field xpath="@number"/>

               <element name="parts" type="r:PartsType"/>
          <attribute name="period"       type="duration"/>
          <attribute name="periodEnding" type="date"/>

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

     <key name="pNumKey">
          <selector xpath="r:parts/r:part"/>
          <field xpath="@number"/>

Given the important role that the Primer plays in helping people to learn
and develop XML Schemas, if this is in fact an erratum I hope that it will
be possible to take speedy measures to make this clear to readers.

Neil Graham
XML Parser Development
IBM Toronto Lab
Phone:  416-448-3519, T/L 778-3519
E-mail:  neilg@ca.ibm.com
Received on Friday, 22 June 2001 17:43:59 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:08:52 UTC