W3C home > Mailing lists > Public > xmlschema-dev@w3.org > September 2005

RE: key-keyref constraints: conflicts in node-table

From: Kasimier Buchcik <K.Buchcik@4commerce.de>
Date: Mon, 26 Sep 2005 22:18:56 +0200
To: Michael Kay <mike@saxonica.com>
Cc: XML-SCHEMA <xmlschema-dev@w3.org>
Message-Id: <1127765936.1272.184.camel@librax>


On Mon, 2005-09-26 at 20:21 +0100, Michael Kay wrote:
> > 
> > A strategy which would follow this assumption could look like
> > (but only semantically, since this is not streamable):
> > 
> > 1. Build the sum of all qualified node sets of all scope elements
> >   of the referenced IDC key/unique definition in the
> >   descendant-or-self axis, starting with a scope element
> >   of the keyref.
> > 
> > 2. Remove all nodes with identical key-sequences from this set.
> > 
> > 3. Find a match for the key-sequence of a qualified node of the keyref
> >   in this set.
> > 
> > 4. If no match was found then we get an error, since either
> >   no matching key-sequence existed, or a duplicate existed and
> >   was removed.
> > 
> > Does this make sense?
> I think this is essentially what Saxon is doing today (except that I found a
> bug in the handling of <xs:selector xpath="."/> which is proving very hard
> to fix without stopping everything else from working!). I assume you mean in
> (2) that if you find 2 duplicates, you remove both. (It's nice however to


> give different errors for "no match" and "more than one match".) But what
> worries me is that the way the rule is phrased, removal of duplicates
> depends on whether they bubbled up from a descendant, or were found at the
> top level. I can't see any reason why anyone would want to specify it that
> way, but that's not necessarily a good way of trying to work out what
> this absurdly complex spec actually says.


Yeah, I now noticed that the current wording of the spec seems to be
inconsistent if taking the effects of total elimitation into account.
Here an example:

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">

  <xsd:element name="SECTION">
	    <xsd:element ref="SECTION" minOccurs="0" maxOccurs="2"/>
        <xsd:element name="DEFINITION" minOccurs="0" maxOccurs="5">
            <xsd:attribute name="term" type="xsd:string"/>
        <xsd:element name="TERMREF" type="xsd:string" minOccurs="0"

    <xsd:key name="defKey">
      <xsd:selector xpath="DEFINITION"/>
      <xsd:field xpath="@term"/>

    <xsd:keyref name="termRef" refer="defKey">
      <xsd:selector xpath="TERMREF"/>
      <xsd:field xpath="."/>

<SECTION xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

      <DEFINITION term="zappa"/>
      <DEFINITION term="zappa"/>
    <!--DEFINITION term="zappa"/-->


This will produce an error, since the entries for "zappa" are
eliminated when merging them into the node-table of the 2nd SECTION.
The node-table is empty.

On the other hand, if we uncomment the 3rd DEFINITION, this one
gets perfectly propagated to the 1st SECTION and the keyref should be
happy (and XSV 2.10 is).

So this would produce a mechanism where the success of keyref-
resolution is dependant on a specific constellation of the keys in
the tree - hopefully this is not intended.
I guess this is comparable to your description of the problem, but
demonstrated with the "total elimitation" effect.


Received on Monday, 26 September 2005 20:19:07 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:56:08 UTC