XSD: integer default range

Is there an implied range of default values โ€‹โ€‹when defining an element of a particular data type in an XSD file? For example, if I define an element of type integer:

<xs:element name="MyIntegerElement" type="xs:integer"/> 

Does this have an implied value of min and max for which it will be checked? I know that I can explicitly define valid ranges, for example:

 <xs:element name="MyIntegerElement"> <xs:simpleType> <xs:restriction base="xs:integer"> <xs:minInclusive value="1"/> <xs:maxInclusive value="16"/> </xs:restriction> </xs:simpleType> </xs:element> 

But if I do not do this when I check the XML file against it, will it have a range of valid values โ€‹โ€‹by default? I knew the XSD documentation, but haven't found an answer yet.

+8
xml xsd xml-validation
source share
1 answer

Well, it depends on the data type ...

If you look at the definition of integer in w3 :

The volume value of an integer is an infinite set {..., - 2, -1,0,1,2, ...}

In essence, this means that for integers, by default, there is no range of min / max values, since any integer can be represented.

On the other hand, for int :

(...) maxInclusive should be 2147483647 and minInclusive -2147483648.

The list goes on for longs , shorts , etc.

You can read it in more detail here: http://www.w3.org/TR/xmlschema-2/#typesystem

+7
source share

All Articles