Learn RDF

Menu

XSD Datatype Cheat Sheet

Every information management system needs some way to express primitive datatypes such as integers, numbers, text, dates, or times. For example, does “1” represent a number that can be added with other numbers, or simply text containing the character for the number “1”?

Since the Semantic Web is built on W3C standards, the Semantic Web uses the same familiar datatypes that the W3C built when standardizing XML.

For convenience, we have included this reference guide on XSD datatypes. Most of the descriptions are taken from the W3C authoritative standard, which can be found at http://www.w3.org/TR/xmlschema-2/#built-in-primitive-datatypes

Prerequisites

In the Semantic Web, XSD datatypes are only useful in the context of working with RDF. If you haven’t read them, you’ll need to read RDF 101 and RDF Nuts & Bolts.

XSD Datatypes Reference

All XSD datatypes have the namespace http://www.w3.org/2001/XMLSchema#, which is typically shortened using the prefix “xsd”. Often, these datatypes are represented in quotation marks followed by a type identifier as you’ve seen in RDF Nuts & Bolts. For example:

“42”^^xsd:int

The built-in datatypes are:

DataType Description Example Representation
xsd:string A character string Hello World
xsd:boolean A true/false value True
xsd:decimal Those real numbers which can be represented decimal format 42.1
There are many built-in types which derive from xsd:decimal. These include:

xsd:integer, xsd:positiveInteger. xsd:nonPositiveInteger, xsd:negativeInteger, xsd:nonNegativeInteger, xsd:long, xsd:int, xsd:short, xsd:byte, xsd:unsignedLong, xsd:unsignedInt, xsd:unsignedShort, xsd:unsignedByte

xsd:float Patterned after single-precision IEEE 32-bit floating point 6.0235e-23
xsd:double Patterned after IEEE 64-bit floating point 6.0235e-23
xsd:duration A duration of time. For example, a period of 5 years, 2 months, and 10 days. P5Y2M10D
xsd:dateTime A date and time together 2002-05-30T09:30:10.5
xsd:time An instant of time that recurs every day 13:04:00
xsd:date Intervals of exactly one day in length 1889-09-24
xsd:gYearMonth A specific Gregorian  month in a specific Gregorian  year 1999-05
xsd:gYear A Gregorian  calendar year 1999
xsd:gMonthDay A Gregorian  date that recurs, specifically a day of the year such as the third of May –05-03
xsd:gDay A Gregorian  day that recurs, specifically a day of the month such as the 27th of the month —27
xsd:gMonth A Gregorian  month that recurs every year. For example, June. –06–
xsd:hexBinary Arbitrary hex-encoded binary data 0047dedbef
xsd:base64Binary Arbitrary Base64-encoded binary data VGhpcyBpcyBzb21lIHRleHQh
xsd:anyURI A Uniform Resource Identifier Reference (URI) http://www.cambridgesemantics.com