Jump to content

Indicators


Recommended Posts

I am using XSD to define a message structure for a service oriented architecture such that:- a message represents a command queue that can contain any number of commands in any order.- the commands are valid for the service that will process them.- each command has unique arguments and responses (i.e. there is no simple definition of a command type).Below is an excerpt from the schema with most of the grizzly details removed:

<xs:element name="Commands">	<xs:complexType>  <xs:choice> 	 <xs:element name="CreateAccount" minOccurs="0" maxOccurs="unbounded" /> 	 <xs:element name="DeleteAccount" minOccurs="0" maxOccurs="unbounded" /> 	 <xs:element name="UpdateAccount" minOccurs="0" maxOccurs="unbounded" />  </xs:choice>	</xs:complexType></xs:element>

I would like to be able to validate a message with the following structure:

<Commands>	<DeleteAccount>... details ...</DeleteAccount>	<UpdateAccount>... details ...</UpdateAccount>	<CreateAccount>... details ...</CreateAccount>	<CreateAccount>... details ...</CreateAccount>	<CreateAccount>... details ...</CreateAccount>	<UpdateAccount>... details ...</UpdateAccount></Commands>

I can't see that any of the existing indicators (all, sequence, choice) allow me to do this. I can get the message to validate with sequence if I forcibly re-order the elements:

<Commands>	<CreateAccount>... details ...</CreateAccount>	<CreateAccount>... details ...</CreateAccount>	<CreateAccount>... details ...</CreateAccount>	<DeleteAccount>... details ...</DeleteAccount>	<UpdateAccount>... details ...</UpdateAccount>	<UpdateAccount>... details ...</UpdateAccount></Commands>

This would force a re-order of the command queue on both the sending and receiving side, which is an unacceptable overhead.I'm still fairly new at this; I hope I'm just missing something. Any help would be welcome.

Link to post
Share on other sites

I found a solution, which is to use <xs:choice maxOccurs="unbounded"/> inside of a <xs:sequence> element. I was not aware that they could be "stacked".

<xs:element name="Commands"><xs:complexType><xs:sequence> <xs:choice maxOccurs="unbounded">  <xs:element name="CreateAccount" minOccurs="0" maxOccurs="unbounded" />  <xs:element name="DeleteAccount" minOccurs="0" maxOccurs="unbounded" />  <xs:element name="UpdateAccount" minOccurs="0" maxOccurs="unbounded" /> </xs:choice> </xs:sequence></xs:complexType></xs:element></xs:schema>

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...