This section describes the built-in primitive datatype, 'gYear', 'gMonth' and 'gDay', that represents years, months and days in Gregorian calendar. Leading and trailing whitespaces are allowed and trimmed. Timezone offset is optional.
XSD 1.1 also provides 3 built-in datatypes, "gYear", "gMonth" and "gDay",
to cover 3 properties within a "date" value with these rules:
The value space of "gYear" is all values of the "year" property
representing all possible years in Gregorian calendar.
The lexical space of "gYear" is all possible "year" values represented in
(year)(timezoneOffset)? patten.
The value space of "gMonth" is all values of the "month" property
representing all possible months in a Gregorian calendar year.
The lexical space of "gMonth" is all possible "gMonth" values represented in
--(month)(timezoneOffset)? patten.
The value space of "gDay" is all values of the "day" property
representing all possible days in a Gregorian calendar month.
The lexical space of "gDay" is all possible "gDay" values represented in
---(day)(timezoneOffset)? patten.
"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 "gYear", "gMonth" and "gDay" datatypes
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
gYear_gMonth_gDay_datatype_test.xsd
gYear_gMonth_gDay_datatype_test.xml
Error:
Line number: 13
Column number: 29
Message: cvc-datatype-valid.1.2.1: '101' is not a valid value for
'gYear'. (Minimum 4 digits needed)
Error:
Line number: 13
Column number: 29
Message: cvc-type.3.1.3: The value ' 101 ' of element 'GYear'
is not valid.
Error:
Line number: 14
Column number: 36
Message: cvc-datatype-valid.1.2.1: '2147483648' is not a valid
value for 'gYear'. (Value out of "int" range)
Error:
Line number: 14
Column number: 36
Message: cvc-type.3.1.3: The value ' 2147483648 ' of element
'GYear' is not valid.
Error:
Line number: 21
Column number: 30
Message: cvc-datatype-valid.1.2.1: '--1' is not a valid value for
'gMonth'. (Minimum 2 digits needed)
Error:
Line number: 21
Column number: 30
Message: cvc-type.3.1.3: The value ' --1 ' of element 'GMonth'
is not valid.
Error:
Line number: 22
Column number: 31
Message: cvc-datatype-valid.1.2.1: '--13' is not a valid value for
'gMonth'. (Value out of "month" range)
Error:
Line number: 22
Column number: 31
Message: cvc-type.3.1.3: The value ' --13 ' of element
'GMonth' is not valid.
Error:
Line number: 29
Column number: 28
Message: cvc-datatype-valid.1.2.1: '---1' is not a valid value for
'gDay'. (Minimum 2 digits needed)
Error:
Line number: 29
Column number: 28
Message: cvc-type.3.1.3: The value ' ---1 ' of element 'GDay'
is not valid.
Error:
Line number: 30
Column number: 29
Message: cvc-datatype-valid.1.2.1: '---32' is not a valid value for
'gDay'. (Value out of "day" range)
Error:
Line number: 30
Column number: 29
Message: cvc-type.3.1.3: The value ' ---32 ' of element
'GDay' is not valid.
Failed with errors: 12