I am working with some old XML/XSD code that requires dates to be in 'ISODateTime' format. I have tried a number of different ISO date/time formats, i.e. with 'T' in the middle, but the validation continues to fail.
Am I missing something obvious? The XML and XSD snippets are below along with the error message.
XSD:
<xs:complexType name="MessageId">
<xs:sequence>
<xs:element name="Id" type="Max35Text"/>
<xs:element name="Credit" type="ISODateTime"/>
</xs:sequence>
</xs:complexType>
XML:
<ParentId>
<Id>unique id</Id>
<Credit>2019-09-27 04:00:00</Credit>
</ParentId> <!-- Fixed by edit -->
Validation error:
ERROR: Element '{urn:iso:std:iso:20022:tech:xsd:tsmt.017.001.03}Credit': '2019-09-27 04:00:00' is not a valid value of the atomic type '{urn:iso:std:iso:20022:tech:xsd:tsmt.017.001.03}ISODateTime'.
I could make your XSD work by changing your date format to xs:dateTime
from the namespace http://www.w3.org/2001/XMLSchema
, in your example this is 2019-09-27T04:00:00
.
I did not find a definition for ISODateTime
, but at W3.org is a definition for date/time formats and the closest I found was xs:dateTime
described here.
So change your XML to (by simply adding the "T" you mentioned)
<?xml version="1.0" encoding="UTF-8"?>
<ParentId>
<Id>unique id</Id>
<Credit>2019-09-27T04:00:00</Credit>
</ParentId>
and this sample XSD
<?xml version="1.0" encoding="utf-8"?>
<xs:schema elementFormDefault="qualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="MessageId">
<xs:sequence>
<xs:element name="Id" type="xs:string"/> <!-- Changed for simplicity -->
<xs:element name="Credit" type="xs:dateTime"/>
</xs:sequence>
</xs:complexType>
<xs:element name="ParentId" type="MessageId" />
</xs:schema>
will validate your XML.