Data Types with XML

Looking at this comprehensive list gives you an idea of the level of granularity in XML. There is a data specification for everything, even spaces!

String Data Types
Data Type Description
xs:string A text string containing all legal characters from the ISO/IEC character set, including all white space characters
xs:normalizedString A text string in which all white space characters are replaced with blank spaces
xs:token A text string in which blank spaces are replaced with a single blank space; opening and closing spaces are removed
xs:NMTOKEN A text string containing valid XML names with no white space
xs:NMTOKENS A list of NMTOKEN data values separated by white space
xs:Name A text string similar to the NMTOKEN data type except that names must begin with a letter or the character ":" or "-"
xs:NCName A "noncolonized name," derived from the Name data type but restricting the use of colons anywhere in the name
xs:ID A unique ID name found nowhere else in the instance document
xs:IDREF A reference to an ID value found in the instance document
xs:IDREFS A list of ID references separated by white space
xs:ENTITIY A value matching an unparsed entity defined in a DTD
xs:ENTITIES A list of entity values matching an unparsed entity defined in a DTD

 

Numeric Data Types
Data Type Description
xs:decimal A decimal number in which the decimal separator is always a dot (.) with a leading + or - character allowed; no non-numeric characters are allowed, nor is exponential notation
xs:integer An integer
xs:nonPositiveInteger An integer less than or equal to zero
xs:negativeInteger An integer less than zero
xs:nonNegativeInteger An integer greater than or equal to zero
xs:positiveInteger An integer greater than zero
xs:float A floating point number allowing decimal values and values in scientific notation; infinite values can be represented by -INF and INF, non-numeric values can be represented by NaN
xs:double A double precision floating point number
xs:boolean A boolean value that has the value true, false, 0, or 1

 

Date and time data types
Data Type Description
xs:datetime A date and time entered in the format yyyy-mm-ddThh:mm:ss where yyyy is the four-digit year, mm is the two-digit month, dd is the two-digit day, T is the time zone, hh is the two-digit hour, mm is the two-digit minute, and ss is the two-digit second
xs:datetime A date entered in the format yyyy-mm-dd
xs:time A time entered in the format hh:mm:ss
xs:gYearMonthDay A date based on the Gregorian calendar entered in the format yyyy-mm-dd (equivalent to xs:date)
xs:gYearMonth A date entered in the format yyyy-mm (no day is specified)
xs:gYear A year entered in the format yyyy
xs:gMonthDay A month and day entered in the format --mm-dd
xs:gMonth A month entered in the format --mm
xs:gDay A day entered in the format ---dd
xs:duration A time duration entered in the format PyYmMdDhHmMsS where y, m, d, h, m, and s are the duration values in years, months, days, hours, minutes, and seconds; an optional negative sign is also permitted to indicate a negative time duration.