XSD – Miscellaneous Data Types

  • Post author:
  • Post category:XSD
  • Post comments:0 Comments

XSD has a few other important data types, such as Boolean, binary, and anyURI.

<xs:boolean> data type

The <xs:boolean> data type is used to represent true, false, 1 (for true) or 0 (for false) value.

<xs:boolean> Example

Element declaration in XSD −

<xs:element name = "pass" type = "xs:boolean"/>

Element usage in XML −

<pass>false</pass>

Binary data types

The Binary data types are used to represent binary values. Two binary types are common in use.

  • base64Binary − represents base64 encoded binary data
  • hexBinary − represents hexadecimal encoded binary data

<xs:hexbinary> Example

Element declaration in XSD −

<xs:element name = "blob" type = "xs:hexBinary"/>

Element usage in XML −

<blob>9FEEF</blob>

<xs:anyURI> data type

The <xs:anyURI> data type is used to represent URI.

<xs:anyURI> Example

Element declaration in XSD −

<xs:attribute name = "resource" type = "xs:anyURI"/>

Element usage in XML −

<image resource = "https://www.adglob.in/images/smiley.jpg" />

Numeric Data Types

Following is the list of commonly used numeric data types.

S.No.Name & Description
1.byteA signed 8 bit integer
2.decimalA decimal value
3.intA signed 32 bit integer
4.integerAn integer value
5.longA signed 64 bit integer
6.negativeIntegerAn integer having only negative values (..,-2,-1)
7.nonNegativeIntegerAn integer having only non-negative values (0,1,2,..)
8.nonPositiveIntegerAn integer having only non-positive values (..,-2,-1,0)
9.positiveIntegerAn integer having only positive values (1,2,..)
10.shortA signed 16 bit integer
11.unsignedLongAn unsigned 64 bit integer
12.unsignedIntAn unsigned 32 bit integer
13.unsignedShortAn unsigned 16 bit integer
14.unsignedByteAn unsigned 8 bit integer

Restrictions

Following types of restrictions can be used with Miscellaneous data types except on boolean data type −

  • enumeration
  • length
  • maxLength
  • minLength
  • pattern
  • whiteSpace

Leave a Reply