XSD MiscellaneousData Types


Other miscellaneous data types include boolean, base64Binary, hexBinary, float, double, anyURI, anyURI, and NOTATION.


Boolean Data Type

Boolean data type is used to specify true or false values.

Below is an example of a logical declaration in a schema:

<xs:attribute name="disabled" type="xs:boolean"/>

An element in the document should look like this:

<prize disabled="true">999</prize>

Note:Legal boolean values are true, false, 1 (which indicates true) and 0 (which indicates false).


Binary Data Types

Binary data types are used to express data in binary form.

We can use two binary data types:

  • base64Binary (binary data encoded in Base64)
  • hexBinary (binary data encoded in hexadecimal)

Below is an example of a hexBinary declaration in a schema:

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


AnyURI Data Type

The anyURI data type is used to specify a URI.

Below is an example of an anyURI declaration in a schema:

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

An element in the document should look like this:

<pic src="http://www.w3schools.com/images/smiley.gif" />

Note:If a URI contains spaces, replace them with %20.


Miscellaneous Data Types

Name Description
anyURI  
base64Binary  
boolean  
double  
float  
hexBinary  
NOTATION  
QName  


Restriction on Miscellaneous Data Types

Restrictions that can be used with miscellaneous data types:

  • enumeration (the boolean data type cannot use this constraint*)
  • length (the boolean data type cannot use this constraint)
  • maxLength (the boolean data type cannot use this constraint)
  • minLength (the boolean data type cannot use this constraint)
  • pattern
  • whiteSpace

*Translator's note:The term 'constraint' refers to constraint.

Other extensions