Simple Schema Element/Attribute/Restriction problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andy Howden

    #1

    Simple Schema Element/Attribute/Restriction problem

    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="allPeriod Data">
    <xs:complexType >
    <xs:sequence>
    <xs:element name="periodDat a" maxOccurs="50">
    <xs:complexType >
    <xs:sequence>
    <xs:element name="periodVal ue" type="xs:decima l"/>
    </xs:sequence>
    <xs:attribute name="periodID" use="required">
    <xs:simpleTyp e>
    <xs:restricti on base="xs:intege r">
    <xs:minInclusiv e value="1"/>
    <xs:maxInclusiv e 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
Working...