Jump to content

Indicators


weirriver

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