XSD Tutorial – XSD Numeric Data Type

XSD Tutorial covers topics on XSD Data XSD Tutorial covers topic on XSD Data Types, XSD Text , XSD Mixed, XSD Indicators, XSD Substitution ,XSD Examples, XSD Numeric, XSD Elements.

We discuss XSD Numeric Data Type in detail

The XSD Numeric data are used to depicts the XML data in the form of Integer and Decimal.

<xs:integer> numeric data type

<xs:integer> data type depicts the integer value in the XML document

<xs:integer> example:

<xs:element name=”age” type=“xs:integer”/>

<age>28</age>

<xs:decimal> data type

<xs:decimal> data type depicts the decimal value in the XML document

<xs:decimal> example:

<xs:element name=”price” type=“xs:decimal”/>

<age>20.50</age>

Numeric Data Types

S. No       Name Description
1 byte value with 8-bit integer 
2 decimal decimal value 1.15
3 int value with 32-bit integer 
4 integer integer value
5 long value with 64-bit integer 
6 negativeInteger an integer with negative values (-1,-2,-3…)
7 nonNegativeInteger an integer with negative values (0,1,2…)
8 nonPostiveInteger an integer with non positive values  (0,-1,-2…)
9 positiveInteger an integer with positive values (1,2…)
10 short an unsigned 16-bit integer
11 unsignedShort an unsigned 16-bit integer
12 unsignedLong an unsigned 64-bit integer
13 unsignedInt an unsigned 32-bit integer
14 unsignedByte an unsigned 8-bit integer

XSD Tutorial – XSD Date and Time

XSD Tutorial covers topics on XSD Data Types, XSD Date, XSD Empty, XSD Text , XSD Mixed, XSD Indicators, XSD Substitution ,XSD Examples, XSD Numeric, XSD Elements .

Lets discuss the XSD Date and Time <xs:date> Data Types in detail

The XSD Date <xs:date> data type depicts the Date and Time format in the XML Document.

<xs:date> format

The <xs:date> format (YYYY-MM-DD) in the XML Document depicts

  • YYYY depicts the Year
  • MM depicts the Month
  • DD depicts the Date

<xs:date> example

The below example depicts the data representation in Date format in the XML document

<xs:element name=”createdDate” type =”xs:date” />

Output : <createdDate>2020-05-07</createdDate>

XSD Date TimeZone

The TimeZone values can be handled in the date by applying the below formats

  • Converting the Date with TimeZone , the date can be appended with “Z” for UTC TimeZone like <createdDate>2020-05-07Z</createdDate>
  • Converting the Date with TimeZone, the data can be appended with Positive or negative time like

<createdDate>2020-05-07-04:00</createdDate> // reduces 4 hours from current system time

<createdDate>2020-05-07+04:00</createdDate> // increases 4 hours from current system time

<xs:time> data type

<xs:time> data type depicts the time in the format hh:mm:ss where

  • hh depicts the hour
  • mm depicts the minute
  • ss depicts the second

<xs:time> example:

<xs:element name=”creationTime” type =”xs:time”/>

<creationTime>05:07:21</creationTime>

<xs:datetime> data type

<xs:date> data type depicts the date format (YYYY-MM-DD)

<xs:time> data type depicts the time format (hh:mm:ss)

<xs:datetime> data type depicts the date and time format together (YYYY-MM-DDThh:mm:ss) where

  • YYYY depicts the Year
  • MM depicts the Month
  • DD depicts the Date
  • T depicts the start of the Time vlaue
  • hh depicts the hour
  • mm depicts the minute
  • ss depicts the second

<xs:element name=”creationDateTime” type =”xs:datetime”/>

<creationDateTime>2020-05-07T05:07:21</creationDateTime>

<xs:duration> data type

<xs:duration> depicts the time interval using ” PnYnMnDTnHnMnS ” format where

  • P depicts the period (required)
  • nY depicts the number of years
  • nM depicts the number of months
  • nD depicts the number of days
  • T depicts the start of a time vlaue
  • nH depicts the number of hours
  • nM depicts the number of minutes
  • nS depicts the number of seconds

<xs:duration> example

<xs:duration>P1Y</xs:duration> // depicts period of 1 year

<xs:duration>P1Y2M</xs:duration> // depicts period of 1 year 2 month

<xs:duration>P1Y2M3D</xs:duration> // depicts period of 1 year 2 month 3 Days