Simple Schema Element/Attribute/Restriction problem

Discussion in 'XML' started by Andy Howden, Oct 20, 2003.

  1. Andy Howden

    Andy Howden Guest

    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
    Andy Howden, Oct 20, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    354
  2. Replies:
    3
    Views:
    415
    Priscilla Walmsley
    Jan 25, 2005
  3. Gazza
    Replies:
    1
    Views:
    1,121
    Henry S. Thompson
    Dec 5, 2005
  4. tankbattle
    Replies:
    1
    Views:
    795
    George Bina
    Jul 21, 2006
  5. PeteOlcott
    Replies:
    1
    Views:
    942
    Mukul Gandhi
    Feb 5, 2009
Loading...

Share This Page