Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XSD: default integer value range

Is there an implied default value range when defining an element of a specific 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 min and max value that it will validate to? I know I can explicitly define the valid ranges like so:

<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 don't do this when I validate an XML file against this will it default to a range of valid values? I've been digging around in the XSD documentation but haven't found the answer yet.

like image 326
Jeff Avatar asked Mar 18 '13 20:03

Jeff


People also ask

What is XSD integer?

Description. The value space of xsd:int is the set of common single-size integers (32 bits), the integers between -2147483648 and 2147483647. Its lexical space allows any number of insignificant leading zeros.

What is XSD number?

Description. xsd:decimal is the datatype that represents the set of all decimal numbers with arbitrary lengths. Its lexical space allows any number of insignificant leading and trailing zeros (after the decimal point).

Is XSD mandatory for XML?

An Attribute can appear 0 or 1 times within a given element in the XML document. Attributes are either optional or mandatory (by default they are optional). The "use" property in the XSD definition is used to specify if the attribute is optional or mandatory.


1 Answers

Well, it depends on the data type...

If you look at the definition of integer at w3:

The value space of integer is the infinite set {...,-2,-1,0,1,2,...}

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

On the other hand, for an int:

(...) maxInclusive to be 2147483647 and minInclusive to be -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

like image 166
Francisco Paulo Avatar answered Oct 05 '22 15:10

Francisco Paulo