XML : How to limit defined comlpexType in XSD Schema file

I have defined a object sub-type in an XSD file as such:

    <xs:comlpexType  name="object">      <xs:sequence>        <xs:element name="state"  maxOccurs="undefined"  type="xs:string"/>      </xs:sequence>    </xs:comlpexType>    

As you can see, the < state> tag is configured so that it can appear any number of times (from 1). So this would be an example, where I use the defined < object>:

    <System>      <object_1>        <state>string_1</state>        <state>string_2</state>        <state>string_3</state>      <object_1>      <object_2>        <state>string_4</state>      <object_2>      ...    </System>    

However, there is a special situation where I need to define an object sub-type (< object_n >) with exactly 2 < state > elements/tags (no more and no less):

  <object_n>    <state>string_n1</state>    <state>string_n2</state>  </object_n>    

Is there a way to extend/modify/limit this type when I declare it in a Schema file so that it is clear that it must contain only two sub-elements?

  <xs:element  type="object">    <xs:somewayToLimitChildren/>    

Actually, the object sub-type is more comlpex, hence the need to make it a sub-type.

No comments:

Post a Comment