Hello to everyone in XML schema land.I am only new to the world of XML and schemas, so forgive me if I am asking a stupid question.I seem to have run into a limitation when creating a schema, and I do not see any logical reason for the limitation, so I'm hoping there is a way around it.The problem I have is as follows.I have written the following section of schema code.
<xsd:element name="Size"> <xsd:complexType> <xsd:sequence> <xsd:choice> <xsd:sequence> <xsd:element name="minHeight" minOccurs="0" type="xsd:int"/> <xsd:element name="maxHeight" minOccurs="0" type="xsd:int"/> </xsd:sequence> <xsd:element name="Height" type="xsd:int"/> </xsd:choice> <xsd:choice> <xsd:sequence> <xsd:element name="minWidth" minOccurs="0" type="xsd:int"/> <xsd:element name="maxWidth" minOccurs="0" type="xsd:int"/> </xsd:sequence> <xsd:element name="Width" type="xsd:int"/> </xsd:choice> </xsd:sequence> </xsd:complexType></xsd:element>
As you can see, I have set it up so that I have the option in my associated XML file to specify either min and/or max height, or a specific height value. The same goes for width.This is pretty much what I want, except for a basic limitation in that the <sequence> indicator forces the included elements to be specified in the order they are listed in the schema.In my associated XML file, I do not care if I specify Min before Max, nor do I care if I specify Height before Width. Even the software I have written to parse the xml files does not care about the order the entries are specified. The only thing that seems to care is the w3 schema rules.The obvious solution to this is to use the <all> indicator, but I cannot use this in conjunction with a <choice> or <sequence> indicator.The other idea I had was to change the code so something like
<xsd:element name="Size"> <xsd:complexType> <xsd:choice minOccurs="2" maxOccurs="2"> <xsd:choice> <xsd:choice minOccurs="1" maxOccurs="2"> <xsd:element name="minHeight" minOccurs="0" type="xsd:int"/> <xsd:element name="maxHeight" minOccurs="0" type="xsd:int"/> </xsd:choice> <xsd:element name="Height" type="xsd:int"/> </xsd:choice> . . .
This has the problem, however, that I there is now nothing stopping me from specifying the <minHeight> element twice (or the <maxHeight> element twice), in my XML file, which I do not want.If anyone has any ideas one how to set up the schema to emulate the functionallity of the <all> indicator, it would be greatly appreciated.Thanks,Scott.