"dateTimeStamp" Datatype Values and Representations

This section describes the built-in primitive datatype, 'dateTimeStamp' that represents moments of time in Gregorian calendar. Leading and trailing whitespaces are allowed and trimmed. Timezone offset is required.

"dateTimeStamp" is a built-in datatype derived from "dateTime" datatype introduced in XSD 1.1 to represent a moment of time in the Gregorian calendar system with these rules:

To verify these rules, I wrote this simple XSD document that uses "dateTimeStamp" datatype to declare XML elements:

<?xml version="1.1"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- dateTimeStamp_datatype_test.xsd
 - Copyright (c) 2002-2013 HerongYang.com. All Rights Reserved.
-->
<xs:element name="DateTimeStamp_Datatype_Test">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="DateTimeStamp" type="xs:dateTimeStamp"
         maxOccurs="unbounded"/>
    </xs:sequence>
  </xs:complexType>
</xs:element>
</xs:schema>

Here is a sample XML document that can be used to test these declarations:

<?xml version="1.1"?>
<!-- dateTimeStamp_datatype_test.xml
 - Copyright (c) 2002-2013 HerongYang.com. All Rights Reserved.
-->
<DateTimeStamp_Datatype_Test>

<!-- 4 valid "DateTimeStamp" elements -->
  <DateTimeStamp>    1971-05-16T00:00:01Z    </DateTimeStamp>
  <DateTimeStamp>    1971-05-16T00:00:01.123456780000Z</DateTimeStamp>
  <DateTimeStamp> 345671971-05-16T00:00:01Z    </DateTimeStamp>
  <DateTimeStamp>    1971-05-16T00:00:01+00:00   </DateTimeStamp>

<!-- 3 invalid "DateTimeStamp" elements -->
  <DateTimeStamp>    1971-05-16T00:00:01    </DateTimeStamp>
  <DateTimeStamp>    1971-05-16-05:00</DateTimeStamp>
  <DateTimeStamp>    00:00:01+00:00   </DateTimeStamp>
</DateTimeStamp_Datatype_Test>

Since "dateTimeStamp" is introduced in XSD 1.1, I need to use my Xsd11SchemaValidator.java program presented earlier in the book with Xerces2 XML Schema 1.1 JAR files to run the test:

herong> type java_xerces.bat
java -cp .;.\xerces-2_12_1-xml-schema-1.1\xml-apis.jar;
^^^.\xerces-2_12_1-xml-schema-1.1\xercesImpl.jar;
^^^.\xerces-2_12_1-xml-schema-1.1\serializer.jar;
^^^.\xerces-2_12_1-xml-schema-1.1\resolver.jar.jar;
^^^.\xerces-2_12_1-xml-schema-1.1\org.eclipse.wst.xml.xpath2.processor_1.2.0.jar;
^^^.\xerces-2_12_1-xml-schema-1.1\xercesSamples.jar; %1 %2 %3 %4 %5 %6

herong> java_xerces2 Xsd11SchemaValidator.java
^^^ dateTimeStamp_datatype_test.xsd dateTimeStamp_datatype_test.xml

Error:
   Line number: 14
   Column number: 61
   Message: cvc-datatype-valid.1.2.1: '1971-05-16T00:00:01' is not a
   valid value for 'dateTimeStamp'. (Missing "timezoneOffset")

Error:
   Line number: 14
   Column number: 61
   Message: cvc-type.3.1.3: The value '    1971-05-16T00:00:01    '
   of element 'DateTimeStamp' is not valid.

Error:
   Line number: 15
   Column number: 54
   Message: cvc-datatype-valid.1.2.1: '1971-05-16-05:00' is not a
   valid value for 'dateTimeStamp'. (Missing "time" value)

Error:
   Line number: 15
   Column number: 54
   Message: cvc-type.3.1.3: The value '    1971-05-16-05:00' of
   element 'DateTimeStamp' is not valid.

Error:
   Line number: 16
   Column number: 55
   Message: cvc-datatype-valid.1.2.1: '00:00:01+00:00' is not a valid
   value for 'dateTimeStamp'. (Missing "date" value)

Error:
   Line number: 16
   Column number: 55
   Message: cvc-type.3.1.3: The value '    00:00:01+00:00   ' of
   element 'DateTimeStamp' is not valid.

Failed with errors: 6

Table of Contents

 About This Book

 Introduction to XML Schema

 XML Editor and Schema Processor - XMLPad

 Java API for XML Processing - JAXP

 JAXP - XML Schema (XSD) Validation

 Xerces2 Java Parser - Java API of XML Parsers

 Using Xerces2 Java APIs

 XML Schema Language - Basics

 Introduction of XSD Built-in Datatypes

 "string" and Its Derived Datatypes

 "decimal" and Its Derived Datatypes

"dateTime" and Its Related Datatypes

  Date/Time Seven-Property Model

 "dateTime" Datatype Values and Representations

"dateTimeStamp" Datatype Values and Representations

 "date" Datatype Values and Representations

 "time" Datatype Values and Representations

 "gYear", "gMonth" and "gDay" Datatypes

 "gYearMonth" and "gMonthDay" Datatypes

 "duration" Datatype Values and Representations

 "yearMonthDuration" Datatype Values and Representations

 "dayTimeDuration" Datatype Values and Representations

 Date, Time and Duration Datatype Summary

 Miscellaneous Built-in Datatypes

 Facets, Constraining Facets and Restriction Datatypes

 "simpleType" - Defining Your Own Simple Datatypes

 Complex Element Declaration

 Identity-Constraints: unique, key and keyref

 Assertion as Custom Validation Rules

 XML Schema Location and Namespace in XML Documents

 Overriding Element Types in XML Documents

 Linking Multiple Schema Documents Together

 Glossary

 Archived Tutorials

 References

 Full Version in PDF/EPUB