471,066 Members | 1,283 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,066 software developers and data experts.

Wrapped recursive elements--"boxes and bags"


I've been struggling to create a valid XML schema that implements the following innocent-looking concept:

A box may contain a bunch of bags (possibly 0).
A bag must contain a bunch of boxes (at least 1).

It seems like a simple extension on the well-known doll concept:
A doll may contain a bunch of dolls (possibly 0).
whose simple solution is, for example:
<xsd:element name="doll" type="dollType"/>
<xsd:complexType name="dollType">
<xsd:element ref="doll" minOccurs="0" maxOccurs="unbounded"/>
The only difference with the boxes-and-bags problem is that bags are "wrappers" for the recursion on boxes. But in both cases, the recursion has an opportunity to terminate.

Every variation of this schema I've tried in VS2005 has failed, for example:
<xsd:element name="box" type="boxType"/>
<xsd:element name="bag" type="bagType"/>
<xsd:complexType name="boxType">
<xsd:sequence minOccurs="0" maxOccurs="unbounded">
<xsd:element ref="branch" minOccurs="0" maxOccurs="unbounded">
<xsd:complexType name="bagType">
<xsd:element ref="box" minOccurs="1" maxOccurs="unbounded"/>

Is what I'm attempting to do simply illicit or am I just missing something?

Thanks much,

Dec 2 '06 #1
0 1159

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by Juan Carlos CORUÑA | last post: by
2 posts views Thread by | last post: by
7 posts views Thread by Jon Slaughter | last post: by
reply views Thread by Dave | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.