The numeric datatypes are built on top of four primitive datatypes: xs:decimal for all the decimal types (including the integer datatypes, considered decimals without a fractional part), xs:double and xs:float for single and double precision floats, and xs:boolean for Booleans. Whitespaces are collapsed for all these datatypes.
The datatypes covered in this section are shown in Figure 4-3.
All decimal types are derived from the xs:decimal primary type and constitute a set of predefined types that address the most common usages.
Leading and trailing zeros are not significant and may be trimmed. The decimal separator is always a dot ("."); a leading sign ("+" or "-") may be specified and any characters other than the 10 digits (including whitespaces) are forbidden. Scientific notation ("E+2") is also forbidden and has been reserved to the float datatypes only.
Valid values for xs:decimal include:
123.456
+1234.456
-1234.456
-.456
-456
The following values are invalid:
1 234.456 (spaces are forbidden)
1234.456E+2 (scientific notation ("E+2") is forbidden)
+ 1234.456 (spaces are forbidden)
+1,234.456 (delimiters between thousands are forbidden)
xs:integer is the only datatype directly derived from xs:decimal.
Valid values for xs:integer include:
123456
+00000012
-1
-456
The following values are invalid:
1 234 (spaces are forbidden)
1. (the decimal separator is forbidden)
+1,234 (delimiters between thousands are forbidden).
xs:integer has given birth to three derived datatypes: xs:nonPositiveInteger and xs:nonNegativeInteger (which have still an unlimited length) and xs:long (to fit in a 64-bit word).
These datatypes accept several "special" values: positive zero (0), negative zero (-0) (which is greater than positive 0 but less than any negative value), infinity (INF) (which is greater than any value), negative infinity (-INF) (which is less than any float, and "not a number" (NaN).
Valid values for xs:float and xs:double include:
123.456
+1234.456
-1.2344e56
-.45E-6
INF
-INF
NaN
The following values are invalid:
1234.4E 56 (spaces are forbidden)
1E+2.5 (the power of 10 must be an integer)
+INF (positive infinity doesn't expect a sign)
NAN (capitalization matters in special values)
Copyright © 2002 O'Reilly & Associates. All rights reserved.