Jump to content

How to set restriction in a complexType?


sleax
 Share

Recommended Posts

Hi to all!I've a question to ask to you.If i have a simple type, i know how to set any restriction, like this:

....<xs:element name="age" type="integer"><xs:simpleType>  <xs:restriction base="xs:integer">   <xs:minInclusive value="3"/>   <xs:maxInclusive value="10"/>  </xs:restriction></xs:simpleType></xs:element>....

So i can only put a integer number included among [3,10].if i want to do this in a complexType like here

...<xs:element name="person"><xs:complexType><xs:sequence>  <xs:element name="age" type="xs:integer">...</xs:sequence></xs:complexType></xs:element>....

it should be something like this

...<person><age>99</age></person>...

but if i want to set limits to integer value age?

Link to comment
Share on other sites

You need to define your own simple type, and then set THAT type as the type of the element(s) you want it on - in this case, the "age" element.So for example:

<xs:element name="person"><xs:complexType><xs:sequence>  <xs:element name="age" type="childAge">...</xs:sequence></xs:complexType></xs:element><xs:simpleType name="childAge">  <xs:restriction base="xs:integer">   <xs:minInclusive value="3"/>   <xs:maxInclusive value="10"/>  </xs:restriction></xs:simpleType>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...