This section describes the built-in primitive datatypes, 'long', 'int', 'short' and 'byte', that represents signed integer numbers for different storage sizes. Leading and trailing whitespaces are allowed and trimmed.
Based on the "integer" datatype, 4 other built-in datatypes are derived in XSD 1.1 to
represent signed integer numbers within different storage sizes: "long", "int", "short" and "byte".
Their definitions can be summarized as:
The value space of "long" is all signed integer numbers that can be stored in a 64-bit space.
"long" values are in the range of -9223372036854775808 and 9223372036854775807.
The value space of "int" is all signed integer numbers that can be stored in a 32-bit space.
"int" values are in the range of: -2147483648 and 2147483647.
The value space of "short" is all signed integer numbers that can be stored in a 16-bit space.
"short" values are in the range of: -32768 and 32767.
The value space of "byte" is all signed integer numbers that can be stored in a 8-bit space.
"byte" values are in the range of: -128 and 127.
Lexical spaces of "long", "int", "short" and "byte"
are all possible values in their value spaces represented in decimal format
with with leading and trailing whitespaces allowed and trimmed.
Leading zeroes are optional.
Decimal point is not allowed.
"long", "int", "short" and "byte" lexical representations after whitespaces are trimmed should match this regular expression:
/[\-+]?[0-9]+/.
To verify these rules, I wrote this simple XSD document that uses "long", "int", "short" and "byte" datatypes
to declare XML elements:
When validating this XML document with my XsdSchemaValidator.java program presented earlier in the book,
I get 8 groups of errors for 8 invalid XML elements:
c:\Progra~1\Java\jdk1.7.0_07\bin\java XsdSchemaValidator
long_int_short_byte_datatype_test.xsd
long_int_short_byte_datatype_test.xml
Error:
Line number: 11
Column number: 36
Message: cvc-minInclusive-valid: Value '-9223372036854775809' is
not facet-valid with respect to minInclusive '-9223372036854775808'
for type 'long'.
Error:
Line number: 11
Column number: 36
Message: cvc-type.3.1.3: The value '-9223372036854775809' of
element 'Long' is not valid.
Error:
Line number: 12
Column number: 36
Message: cvc-maxInclusive-valid: Value '9223372036854775808' is not
facet-valid with respect to maxInclusive '9223372036854775807' for
type 'long'.
Error:
Line number: 12
Column number: 36
Message: cvc-type.3.1.3: The value ' 9223372036854775808' of
element 'Long' is not valid.
Error:
Line number: 19
Column number: 30
Message: cvc-minInclusive-valid: Value '-2147483649' is not facet-
valid with respect to minInclusive '-2147483648' for type 'int'.
Error:
Line number: 19
Column number: 30
Message: cvc-type.3.1.3: The value ' -2147483649 ' of element
'Int' is not valid.
Error:
Line number: 20
Column number: 30
Message: cvc-maxInclusive-valid: Value '2147483648' is not facet
-valid with respect to maxInclusive '2147483647' for type 'int'.
Error:
Line number: 20
Column number: 30
Message: cvc-type.3.1.3: The value ' 2147483648 ' of element
'Int' is not valid.
Error:
Line number: 27
Column number: 29
Message: cvc-minInclusive-valid: Value '-32769' is not facet-valid
with respect to minInclusive '-32768' for type 'short'.
Error:
Line number: 27
Column number: 29
Message: cvc-type.3.1.3: The value ' -32769 ' of element 'Short'
is not valid.
Error:
Line number: 28
Column number: 29
Message: cvc-maxInclusive-valid: Value '32768' is not facet-valid
with respect to maxInclusive '32767' for type 'short'.
Error:
Line number: 28
Column number: 29
Message: cvc-type.3.1.3: The value ' 32768 ' of element 'Short'
is not valid.
Error:
Line number: 35
Column number: 25
Message: cvc-minInclusive-valid: Value '-129' is not facet-valid
with respect to minInclusive '-128' for type 'byte'.
Error:
Line number: 35
Column number: 25
Message: cvc-type.3.1.3: The value ' -129 ' of element 'Byte' is
not valid.
Error:
Line number: 36
Column number: 25
Message: cvc-maxInclusive-valid: Value '128' is not facet-valid
with respect to maxInclusive '127' for type 'byte'.
Error:
Line number: 36
Column number: 25
Message: cvc-type.3.1.3: The value ' 128 ' of element 'Byte' is
not valid.
Failed with errors: 16