This section describes the built-in primitive datatype, 'date' that represents dates in Gregorian calendar. Leading and trailing whitespaces are allowed and trimmed. Timezone offset is optional.
The "dateTime" datatype can be easily divided into 2 datatypes:
"date" - Using "year", "month" and "day" properties only to represent dates.
"time" - Using "hour", "minute" and "second" properties only to represent moments of time
within a day.
Let's look at "date" first in this tutorial.
"date" is a built-in datatype that uses the date/time seven-property model
to represent a date in the Gregorian calendar system with these rules:
The value space of "date" is all possible dates in Gregorian calendar with
"year" in the range of -2147483648 and 2147483647.
The lexical space of "date" is all possible "date" values represented in
(year)-(month)-(date)(timezoneOffset)? patten.
"year", "month" and "date" 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 "date" datatype to declare XML elements:
When validating this XML document with my XsdSchemaValidator.java program presented earlier in the book,
I get 4 groups of errors for 4 invalid XML elements:
c:\Progra~1\Java\jdk1.7.0_07\bin\java XsdSchemaValidator
date_datatype_test.xsd date_datatype_test.xml
Error:
Line number: 14
Column number: 31
Message: cvc-datatype-valid.1.2.1: '05-16' is not a valid value
for 'date'. (Missing "year")
Error:
Line number: 14
Column number: 31
Message: cvc-type.3.1.3: The value ' 05-16 ' of element
'Date' is not valid.
Error:
Line number: 15
Column number: 40
Message: cvc-datatype-valid.1.2.1: '1971-05-16T00:00:00' is not a
valid value for 'date'. ("time" not allowed)
Error:
Line number: 15
Column number: 40
Message: cvc-type.3.1.3: The value ' 1971-05-16T00:00:00 ' of
element 'Date' is not valid.
Error:
Line number: 16
Column number: 32
Message: cvc-datatype-valid.1.2.1: '12-05-16' is not a valid value
for 'date'. ("year" must have 4 digits or longer)
Error:
Line number: 16
Column number: 32
Message: cvc-type.3.1.3: The value ' 12-05-16 ' of element
'Date' is not valid.
Error:
Line number: 17
Column number: 28
Message: cvc-datatype-valid.1.2.1: '001234-05-31' is not a valid
value for 'date'. ("year" with more than 4 digits can not have
leading 0)
Error:
Line number: 17
Column number: 28
Message: cvc-type.3.1.3: The value '001234-05-31' of element 'Date'
is not valid.
Failed with errors: 8