A
Andy Howden
I'm trying to define a schema element (allPeriodData) containing up to 50 different decimal child elements (periodData). Each child element (periodData) identifies itself with an ID having a value from 1 to 50.
Each child element is optional (i.e. there don't have to be 50 altogether) but each ID (1-50) may occur only once within the parent element.
The best definition I have so far is this:
<xs:element name="allPeriodData">
<xs:complexType>
<xs:sequence>
<xs:element name="periodData" maxOccurs="50">
<xs:complexType>
<xs:sequence>
<xs:element name="periodValue" type="xs:decimal"/>
</xs:sequence>
<xs:attribute name="periodID" use="required">
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:minInclusive value="1"/>
<xs:maxInclusive value="50"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
but, this allows the same attribute value (periodID) to be held by different periodData elements within the allPeriodData element.
I've tried to enumerate all 50 possibilities and fixing the attribute value of each, but the schema isn't valid unless each periodData element has a unique name, which I really don't want.
I feel pretty sure that this is a common thing to try to do.
Any suggestions very much appreciated.
Andy
Each child element is optional (i.e. there don't have to be 50 altogether) but each ID (1-50) may occur only once within the parent element.
The best definition I have so far is this:
<xs:element name="allPeriodData">
<xs:complexType>
<xs:sequence>
<xs:element name="periodData" maxOccurs="50">
<xs:complexType>
<xs:sequence>
<xs:element name="periodValue" type="xs:decimal"/>
</xs:sequence>
<xs:attribute name="periodID" use="required">
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:minInclusive value="1"/>
<xs:maxInclusive value="50"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
but, this allows the same attribute value (periodID) to be held by different periodData elements within the allPeriodData element.
I've tried to enumerate all 50 possibilities and fixing the attribute value of each, but the schema isn't valid unless each periodData element has a unique name, which I really don't want.
I feel pretty sure that this is a common thing to try to do.
Any suggestions very much appreciated.
Andy