This section describes the built-in primitive datatype, 'dateTime' that represents moments of time in Gregorian calendar. Leading and trailing whitespaces are allowed and trimmed. Timezone offset is optional.
"dateTime" is a built-in datatype that uses the date/time seven-property model
to represent a moment of time in the Gregorian calendar system
with these rules:
The value space of "dateTime" is all possible moments in time in Gregorian calendar with
"year" in the range of -2147483648 and 2147483647.
The lexical space of "dateTime" is all possible "dateTime" values represented in
(year)-(month)-(day)T(hour):(minute):(second)(timezoneOffset)? patten.
"year", "month", "day", "hour", "minute" and "second" are required properties.
"timezoneOffset" property is optional and no default timezone is defined.
Leading and trailing whitespaces allowed and trimmed.
To verify these rules, I wrote this simple XSD document that uses "dateTime" datatype to declare XML elements:
When validating this XML document with my XsdSchemaValidator.java program presented earlier in the book,
I get 6 groups of errors for 6 invalid XML elements:
c:\Progra~1\Java\jdk1.7.0_07\bin\java XsdSchemaValidator
dateTime_datatype_test.xsd dateTime_datatype_test.xml
Error:
Line number: 15
Column number: 45
Message: cvc-datatype-valid.1.2.1: '05-16T00:00' is not a valid
value for 'dateTime'. (Missing "year" and "second")
Error:
Line number: 15
Column number: 45
Message: cvc-type.3.1.3: The value ' 05-16T00:00 ' of
element 'DateTime' is not valid.
Error:
Line number: 16
Column number: 45
Message: cvc-datatype-valid.1.2.1: '1971-05-16T00:00' is not a
valid value for 'dateTime'. (Missing "second")
Error:
Line number: 16
Column number: 45
Message: cvc-type.3.1.3: The value ' 1971-05-16T00:00 ' of
element 'DateTime' is not valid.
Error:
Line number: 17
Column number: 50
Message: cvc-datatype-valid.1.2.1: '12-05-16T00:00:01Z' is not a
valid value for 'dateTime'. ("year" must have 4 digits or longer)
Error:
Line number: 17
Column number: 50
Message: cvc-type.3.1.3: The value ' 12-05-16T00:00:01Z ' of
element 'DateTime' is not valid.
Error:
Line number: 18
Column number: 56
Message: cvc-datatype-valid.1.2.1:
'001234-05-16T00:00:00.0123456789' is not a valid value for
'dateTime'. ("year" with more than 4 digits can not have leading 0)
Error:
Line number: 18
Column number: 56
Message: cvc-type.3.1.3: The value
'001234-05-16T00:00:00.0123456789' of element 'DateTime' is not
valid.
Error:
Line number: 19
Column number: 62
Message: cvc-datatype-valid.1.2.1:
'-00123456789-05-16T00:00:00.0123456789' is not a valid value for
'dateTime'. ("year" with more than 4 digits can not have leading 0)
Error:
Line number: 19
Column number: 62
Message: cvc-type.3.1.3: The value
'-00123456789-05-16T00:00:00.0123456789' of element 'DateTime' is
not valid.
Error:
Line number: 20
Column number: 54
Message: cvc-datatype-valid.1.2.1: '2147483648-05-16T00:00:01Z' is
not a valid value for 'dateTime'. ("year" is not an "int" value)
Error:
Line number: 20
Column number: 54
Message: cvc-type.3.1.3: The value '2147483648-05-16T00:00:01Z '
of element 'DateTime' is not valid.
Failed with errors: 12