XML Schema Tutorials - Herong's Tutorial Examples
Dr. Herong Yang, Version 4.00

Built-in Datatype - "dateTime" Errors

This section describes a tutorial example on validation errors against dateTime restriction facets.

In the previous section, we created a schema using "dateTime", "date", and "time" datatypes with different restriction facets. Now we are going to create an XML document, datetime_datatype_error.xml, with several validation errors:

<?xml version="1.0"?>
<ticket
 ticketDateTime="2007/02/02T23:59:59"
 departureDate="2017-03-01"
 departureTime="03:30:00"
/>

Here is the output of XsdSchemaValidator.java:

>java XsdSchemaValidator datetime_datatype.xsd
   datetime_datatype_error.xml

Error:
   Line number: 6
   Column number: 3
   Message: cvc-datatype-valid.1.2.1: '2007/02/02T23:59:59' is not
   a valid value for 'dateTime'.

Error:
   Line number: 6
   Column number: 3
   Message: cvc-attribute.3: The value '2007/02/02T23:59:59' of 
   attribute 'ticketDateTime' on element 'ticket' is not valid with
   respect to its type, 'null'.

Error:
   Line number: 6
   Column number: 3
   Message: cvc-maxInclusive-valid: Value '2017-03-01' is not 
   facet-valid with respect to maxInclusive '2009-12-31' for type 
   '#AnonType_departureDateticket'.

Error:
   Line number: 6
   Column number: 3
   Message: cvc-attribute.3: The value '2017-03-01' of attribute 
   'departureDate' on element 'ticket' is not valid with respect 
   to its type, 'null'.

Error:
   Line number: 6
   Column number: 3
   Message: cvc-minInclusive-valid: Value '03:30:00' is not 
   facet-valid with respect to minInclusive '05:00:00.0' for type
   '#AnonType_departureTimeticket'.

Error:
   Line number: 6
   Column number: 3
   Message: cvc-attribute.3: The value '03:30:00' of attribute 
   'departureTime' on element 'ticket' is not valid with respect 
   to its type, 'null'.

Failed with errors: 6

Sections in This Chapter

Overview of XML Schema Built-in Datatypes

List of Built-in Datatypes

Deriving from Built-in Datatypes - simpleType

Built-in Datatype - "string"

Built-in Datatype - "string" Errors

Built-in Datatype - "dateTime"

Built-in Datatype - "dateTime" Errors

Built-in Datatype - "decimal"

Built-in Datatype - "decimal" Errors

Dr. Herong Yang, updated in 2007
Built-in Datatype - "dateTime" Errors