Cecil
19+ years progress programming and still learning.
OE 11.6
OS: WINDOWS
I need to output a DATETIME data type into an XML file but not to include the milliseconds.
I'm currently creating an XML document and the supporting XSD where the timestamp is a CHARACTER data type and I'm outputting them in the following format mask YYYY-MM-DDTHH:MM:SS. However, the XSD show that the timestamp element is of TYPE STRING.
The other party who is importing the timestamp field is expecting DateTIme (YYYY-MM-DDTHH:MM:SS) and not a STRING.
So, using the code below how do I export the timestamp to not include the milliseconds of the ISO-DATE FORMAT and still maintaining the XSD SCHEMA. I have simplified the code for ease, but the real code is using dynamic temp-tables and the other party is dynamically importing the data based on the XSD provided.
THE CODE:
THE XSD:
THE XML Output:
OS: WINDOWS
I need to output a DATETIME data type into an XML file but not to include the milliseconds.
I'm currently creating an XML document and the supporting XSD where the timestamp is a CHARACTER data type and I'm outputting them in the following format mask YYYY-MM-DDTHH:MM:SS. However, the XSD show that the timestamp element is of TYPE STRING.
The other party who is importing the timestamp field is expecting DateTIme (YYYY-MM-DDTHH:MM:SS) and not a STRING.
So, using the code below how do I export the timestamp to not include the milliseconds of the ISO-DATE FORMAT and still maintaining the XSD SCHEMA. I have simplified the code for ease, but the real code is using dynamic temp-tables and the other party is dynamically importing the data based on the XSD provided.
THE CODE:
Code:
DEFINE TEMP-TABLE ttRecord NO-UNDO XML-NODE-NAME "record"
FIELD TimeStamp AS DATETIME XML-NODE-NAME "timestamp".
CREATE ttRecord.
ASSIGN
ttRecord.TimeStamp = DATETIME(TODAY,0).
TEMP-TABLE ttRecord:WRITE-XML('file','record.xml',TRUE).
TEMP-TABLE ttRecord:WRITE-XMLSCHEMA('file','record.xsd',TRUE).
FILE-INFO:FILE-NAME = '.'.
MESSAGE FILE-INFO:FULL-PATHNAME .
THE XSD:
Code:
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="" xmlns:prodata="urn:schemas-progress-com:xml-prodata:0001">
<xsd:element name="record" prodata:proTempTable="true" prodata:tableName="ttRecord">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="recordRow" minOccurs="0" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="timestamp" type="xsd:dateTime" nillable="true" prodata:dataType="prodata:dateTime" prodata:fieldName="TimeStamp"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
THE XML Output:
Code:
<?xml version="1.0"?>
<record xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<recordRow>
<timestamp>2018-11-14T00:00:00.000</timestamp>
</recordRow>
</record>