This section describes the built-in primitive datatype, 'integer' that represents signed integer numbers. Leading and trailing whitespaces are allowed and trimmed.
Based on what we have learned on "decimal" datatype in the previous section,
let's now look at its first derived datatype: integer.
"integer" is a built-in datatype derived from "decimal" datatype to represent signed integer numbers
with these rules:
The value space of "integer" is all possible signed integer numbers.
The lexical space of "integer" is all possible signed integer numbers represented in decimal format
with with leading and trailing whitespaces allowed and trimmed.
Leading zeroes are optional.
Decimal point is not allowed.
A "integer" lexical representation after whitespaces are trimmed should match this regular expression:
/[\-+]?[0-9]+/.
To verify these rules, I wrote this simple XSD document that uses "integer" datatype to declare XML elements:
When validating this XML document with my XsdSchemaValidator.java program presented earlier in the book,
I get 3 groups of errors for 3 invalid XML elements:
c:\Progra~1\Java\jdk1.7.0_07\bin\java XsdSchemaValidator
integer_datatype_test.xsd integer_datatype_test.xml
Error:
Line number: 15
Column number: 30
Message: cvc-datatype-valid.1.2.1: '+ 123456' is not a valid value
for 'integer'.
Error:
Line number: 15
Column number: 30
Message: cvc-type.3.1.3: The value '+ 123456' of element 'Integer'
is not valid.
Error:
Line number: 16
Column number: 32
Message: cvc-datatype-valid.1.2.1: '-1,234,456' is not a valid
value for 'integer'.
Error:
Line number: 16
Column number: 32
Message: cvc-type.3.1.3: The value '-1,234,456' of element
'Integer' is not valid.
Error:
Line number: 17
Column number: 28
Message: cvc-datatype-valid.1.2.1: '12345.' is not a valid value
for 'integer'.
Error:
Line number: 17
Column number: 28
Message: cvc-type.3.1.3: The value '12345.' of element 'Integer'
is not valid.
Failed with errors: 6