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:sequence>
		<xs:element name="activityID" type="xs:int"/>
	</xs:sequence>
</xs:complexType>

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

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

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:key>

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

If I try something like the following in my XML:

<schedActivity>
  <activityID>1</activityID>
</schedActivity>
<schedActivity>
  <activityID>2</activityID>
</schedActivity>
<prodSchedule>
  <schedName>My Schedule</schedName>
  <dayBucket>
    <dayNumber>1</dayNumber>
    <activityRef>1</activityRef>
    <activityRef>2</activityRef>
  </dayBucket>
<prodSchedule>

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.3.1 : Wednesday, 5 February 2014 07:15:10 UTC