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

Understanding Dawns! But 1 More Question About Keys/Refs...

From: Jim Stanley <JimS@Media-Services.Com>
Date: Fri, 30 Jul 2004 16:30:22 -0700
Message-Id: <s10a77b4.034@mail.MEDIA-SERVICES.COM>
To: <xmlschema-dev@w3.org>

George and Michael,

Thanks *so* much!  The clouds have miraculously parted and I'm finally
able to get my schema validating.

One more question:

I don't seem to be able to create one-to-many validation of my keys,
which is a problem because more than one keyed element may occur in a
given sequence:

<xs:complexType name="schedActivity">
		<xs:element name="activityID" type="xs:int"/>

Zero to infinite of those schedActivities need to go in the following:
<xs:complexType name="dayBucket">
		<xs:element name="dayNumber" type="xs:int"/>
		<xs:element name="activityRef" type="xs:int"
minOccurs="0" maxOccurs="unbounded"/>

<xs:complexType name="prodSchedule">
		<xs:element name="schedName" type="xs:string"/>
		<xs:element name="dayBucket" type="dayBucket"
minOccurs="0" maxOccurs="unbounded"/>

I've defined my high-level keys and keyrefs as follows (assume
"document" owns all the above):

<xs:key name="schedActivity.PK">
	<xs:selector xpath="schedActivity"/>
	<xs:field xpath="activityID"/>

<xs:keyref name="schedDayActivity.FK" refer="schedActivity.PK">
	<xs:selector xpath="prodSchedule/dayBucket"/>
	<xs:field xpath="activityRef"/>

If I try something like the following in my XML:

  <schedName>My Schedule</schedName>

XMLSpy tells me that the foreign key has to evaluate to exactly 0 or 1
node.  I need 1 to unbounded, and I also need to make sure that any
activityRef elements have a reference to a declared schedActivity
object.  What am I missing?

Thanks again,

Jim Stanley
Media Services, Inc.
Received on Friday, 30 July 2004 19:31:15 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:15:22 UTC