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 comment
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 comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...