This section describes the built-in primitive datatype, 'gYearMonth' and 'gMonthDay', that represents year-month and month-day combinations in Gregorian calendar. Leading and trailing whitespaces are allowed and trimmed. Timezone offset is optional.
XSD 1.1 also provides 2 built-in datatypes, "gYearMonth" and "gMonthDay"
to cover 2-property combination within a "date" value with these rules:
The value space of "gYearMonth" is all values of "year" and "month" combinations in Gregorian calendar.
The lexical space of "gYearMonth" is all possible "gYearMonth" values represented in
(year)(mont)(timezoneOffset)? patten.
The value space of "gMonthDay" is all values of "month" and "day" combinations in a Gregorian calendar year.
The lexical space of "gMonthDay" is all possible "gMonthDay" values represented in
--(month)-(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 "gYearMonth" and "gMonthDay" 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
gYearMonth_gMonthDay_datatype_test.xsd
gYearMonth_gMonthDay_datatype_test.xml
Error:
Line number: 13
Column number: 42
Message: cvc-datatype-valid.1.2.1: '101-01' is not a valid value
for 'gYearMonth'. ("Year" must be at leat 4 digits)
Error:
Line number: 13
Column number: 42
Message: cvc-type.3.1.3: The value ' 101-01 ' of element
'GYearMonth' is not valid.
Error:
Line number: 14
Column number: 50
Message: cvc-datatype-valid.1.2.1: '2147483648-12Z' is not a valid
value for 'gYearMonth'. ("year" value out of "int" range")
Error:
Line number: 14
Column number: 50
Message: cvc-type.3.1.3: The value ' 2147483648-12Z ' of
element 'GYearMonth' is not valid.
Error:
Line number: 15
Column number: 41
Message: cvc-datatype-valid.1.2.1: '2013Z' is not a valid value for
'gYearMonth'. (Missing "month")
Error:
Line number: 15
Column number: 41
Message: cvc-type.3.1.3: The value ' 2013Z ' of element
'GYearMonth' is not valid.
Error:
Line number: 22
Column number: 38
Message: cvc-datatype-valid.1.2.1: '--1-1' is not a valid value for
'gMonthDay'. (2 digits needed for "month" and "day")
Error:
Line number: 22
Column number: 38
Message: cvc-type.3.1.3: The value ' --1-1 ' of element
'GMonthDay' is not valid.
Error:
Line number: 23
Column number: 46
Message: cvc-datatype-valid.1.2.1: '--13-05-05:00' is not a valid
value for 'gMonthDay'. ("month" value out of range)
Error:
Line number: 23
Column number: 46
Message: cvc-type.3.1.3: The value ' --13-05-05:00 ' of
element 'GMonthDay' is not valid.
Error:
Line number: 24
Column number: 43
Message: cvc-datatype-valid.1.2.1: '--12-05:00' is not a valid
value for 'gMonthDay'. (Missing "day" value)
Error:
Line number: 24
Column number: 43
Message: cvc-type.3.1.3: The value ' --12-05:00 ' of element
'GMonthDay' is not valid.
Failed with errors: 12