Jump to content

mixed occurance limits - a tough one


Guest John Didion

Recommended Posts

Guest John Didion

I have a complex type...let's call it Foo. Foo potentially has five child elements:A and B, each of which MUST appear onceC, D, and E, each of which MAY appear any number of times, but one of which MUST appear at least onceMy first instinct was to write this as an all:<xs:all> <xs:element name="A"/> <xs:element name="B"/> <xs:choice minOccurs="1" maxOccurs="unbounded"> <xs:element name="C"/> <xs:element name="D"/> <xs:element name="E"/> </xs:choice></xs:all>But of cource, all doesn't allow any element to appear more than once. I also tried writing this as a big choice block, with sequences for each of the possible ways these elements could be ordered, but the parser complained about potential ambiguity.Here is the element definition from the DTD that I'm trying to convert to XSD:<!ELEMENT MSGSETLIST ( ( ( ( SIGNONMSGSET, PROFMSGSET ) | ( PROFMSGSET, SIGNONMSGSET ) ), ( %MSGSETMACRO; )+ ) | ( ( ( SIGNONMSGSET, ( %MSGSETMACRO; )+, PROFMSGSET ) | ( PROFMSGSET, ( %MSGSETMACRO; )+, SIGNONMSGSET ) ), ( %MSGSETMACRO; )* ) | ( (%MSGSETMACRO;)+, ( ( SIGNONMSGSET, ( %MSGSETMACRO; )*, PROFMSGSET ) | ( PROFMSGSET, ( %MSGSETMACRO; )*, SIGNONMSGSET ) ), ( %MSGSETMACRO; )* ) )>Thanks in advance for your help!

Link to post
Share on other sites
  • 3 weeks later...
Guest ThosRTanner

I have a similar issue:

I have a complex type...let's call it Foo. Foo potentially has five child elements:A and B, each of which MUST appear onceC, D, and E, each of which MAY appear any number of times, but one of which MUST appear at least onceMy first instinct was to write this as an all:<xs:all> <xs:element name="A"/> <xs:element name="B"/> <xs:choice minOccurs="1" maxOccurs="unbounded"> <xs:element name="C"/> <xs:element name="D"/> <xs:element name="E"/> </xs:choice></xs:all>
I have a type which can have elementsAor Bor one or more of C, D, E (but no duplicates),so you can specifyABCCD (or DC)CDE (or EDC or ...)DDE (or ED)Eafter some thought (I'm very new at this), I came up with a construct involving a choice of A, B and a sequence of up to 3 containing a choice of C, D, E.However, this permits such things as DDD, which I don't really want.Is there any way I can get what I want - it seems to be a fairly common thing to want to do in our environment, there must be some way of doing it, surely?Thanks for any help
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...