∟"dayTimeDuration" Datatype Values and Representations
This section describes the built-in primitive datatype, 'dayTimeDuration' that represents durations of time in units of seconds in Gregorian calendar. Leading and trailing whitespaces are allowed and trimmed. 'dayTimeDuration' values can be stored as 'decimal' values.
"dayTimeDuration" is a built-in datatype derived from "duration" datatype introduced in XSD 1.1
to represent a duration of time in units of seconds with these rules:
The value space of "dayTimeDuration" is all possible durations of time in units of seconds,
by converting the "duDay", "duHour", "duMinute" and "duSecond" properties into seconds as "decimal" values.
The lexical space of "dayTimeDuration" is all possible "dayTimeDuration" values represented in
(duSign)P(duDay)?(T(duHour)?(duMinute)?(duSecond)?)? pattern.
"duDay", "duHour", "duMinute" and "duSecond" are all optional.
But at least one of them must present.
Leading and trailing whitespaces allowed and trimmed.
To verify these rules, I wrote this simple XSD document that uses "dayTimeDuration" datatype to declare XML elements:
Since "dateTimeStamp" is introduced in XSD 1.1,
I need to use my Xsd11SchemaValidator.java program presented earlier in the book
to run the test:
c:\Progra~1\Java\jdk1.7.0_07\bin\java
-cp ".;c:\local\xerces-2_11_0-xml-schema-1.1-beta\xercesImpl.jar;
c:\local\xerces-2_11_0-xml-schema-1.1-beta
\org.eclipse.wst.xml.xpath2.processor_1.1.0.jar"
Xsd11SchemaValidator
dayTimeDuration_datatype_test.xsd dayTimeDuration_datatype_test.xml
Error:
Line number: 18
Column number: 59
Message: cvc-datatype-valid.1.2.1: 'PT2147483648H' is not a valid
value for 'dayTimeDuration'. (Value out of "int" range)
Error:
Line number: 18
Column number: 59
Message: cvc-type.3.1.3: The value ' PT2147483648H ' of
element 'DayTimeDuration' is not valid.
Error:
Line number: 19
Column number: 49
Message: cvc-datatype-valid.1.2.1: 'P1M' is not a valid value for
'dayTimeDuration'. (Months not allowed)
Error:
Line number: 19
Column number: 49
Message: cvc-type.3.1.3: The value ' P1M ' of element
'DayTimeDuration' is not valid.
Error:
Line number: 20
Column number: 52
Message: cvc-datatype-valid.1.2.1: 'PT1S1M' is not a valid value
for 'dayTimeDuration'. (Minutes should be before seconds)
Error:
Line number: 20
Column number: 52
Message: cvc-type.3.1.3: The value ' PT1S1M ' of element
'DayTimeDuration' is not valid.
Failed with errors: 6