keyref with empty sets

I have the following snippet of schema:

  <xs:element name="Admin">

    <xs:complexType mixed="false">

      <xs:sequence>

        <xs:element ref="UserSet"      minOccurs="0" maxOccurs="1"/>

        <xs:element ref="ExperimentSet" minOccurs="0" maxOccurs="1"/>

      </xs:sequence>

    </xs:complexType>

    <xs:keyref name="ExperimentAssocRef" refer="UserKey">

      <xs:selector xpath="ad:ExperimentSet/ad:Experiment"/>

      <xs:field xpath="ad:userID"/>

      <!-- the implementation of ResponsibleFor -->

    </xs:keyref>

  </xs:element>

All experiments must have a user responsible for them. We can have a set 
of users with no associated experiments, but I also want the possibility 
of having an empty Admin element. UserKey is defined over the elements 
of UserSet.

When I set up a test with no experimentSet (but some users in the 
userSet) that's fine.

With a completely empty Admin element I am told there is a "keyref which 
refers to a key or unique that is out of scope" (using Java Xerces).

So I see that when there were just users there were values of UserKey 
but no Experiment happened to refer to them. I had not expected that 
when there were no users either I would have a problem that there were 
no users for experiments not to reference :-)

Where am I adrift?
Thanks

    Nigel




-- 
---------------------------------------------------------------------
Nigel Hardy     Tel: +44 1970 622 434.   http://users.aber.ac.uk/nwh/
  Dept. Computer Sci,  University of Wales, Aberystwyth, SY23 3DB, UK
  Adran Cyfrifiadureg, Prifysgol Cymru,     Aberystwyth, SY23 3DB, UK

Received on Friday, 28 May 2004 06:13:36 UTC