Question HOW DO I MODIFY THE ISO DATE FORMAT MASK?

Cecil

19+ years progress programming and still learning.
#1
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:
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>
 
#2
Cecil,

While a bit 'old school', we've had to do this too within XML.

What we did was define the variable as a character, then set it to iso-date(today) + "T" + string(mytime,"HH:MM:SS")
 

Cecil

19+ years progress programming and still learning.
#3
Cecil,

While a bit 'old school', we've had to do this too within XML.

What we did was define the variable as a character, then set it to iso-date(today) + "T" + string(mytime,"HH:MM:SS")
Hi LarryD,

Thanks for that, I should have explained that is what I am already doing. building up a string value of the ISO-DATE standard but the problem is that I need to have the XML element export a DATATIME field which does not include the milliseconds and it aligns with the XSD being produced.

OpenEdge WRITE-XML() method will automatically convert a DATETIME to ISO-DATE format, but I need it without milliseconds. The XSD for the timestamp field cannot be of type STRING.
 
#4
Does the XSD *have* to be created from the same TT definitions as the XML? It seems to me that the other party has no way to know...

You are already outputting XML in the format that they want (I see "I'm already doing that" above) so why not simply edit the XSD and change the datatype from "string" to "datetime"? The XSD itself is just text -- so it shouldn't be difficult. I guess you would want to script it so that any future changes to the XSD can be easily made without losing your ability to modify it.
 

Cecil

19+ years progress programming and still learning.
#5
Well...I have not heard anything more from the client, I'm guessing having STRING datatype in the XSD is okay.
 
Top