Reputation: 1021
I have a problem generating an XSD. In our application the user can define his own format of data, so the user can define, which data he passes us to a webservice. There he can define, if an element can occur once or often. So I get XML like this:
<WaitForSoap>
<Lastname>last</Lastname>
<Firstname>first</Firstname>
<Birthday>hallo</Birthday>
<Firstname>first</Firstname>
<Firstname>first1</Firstname>
</WaitForSoap>
So what I want now is a XSD which ensures, that lastname, birthday occurs once, firstname occurs 3 times. The order of the elements in WaitForSoap
element should be in any order. So xsd:sequence
is not right to use here; xsd:all
is even not right, because I can't use maxoccurs
there. With xsd:choice
I did not get the right solution.
Any other ideas what I could do?
Upvotes: 1
Views: 69
Reputation: 111726
Your design is needlessly complex. Impose an ordering on Firstname
, Lastname
, and Birthday
and the complexity all goes away. You'll be able to represent your requirements with simple occurrence constraints in XSD 1.0.
If you insist on allowing any ordering, you won't be able to represent your requirements in XSD 1.0. You'll have to use XSD 1.1 and write assertions over WaitForSoap
rather than the more natural minOccurs
and maxOccurs
constraints on its children.
Upvotes: 1