Question WRITE-XML ignores format given to Dataset fields

SanderH

New Member
Hello everyone.

I am currently creating a program that can create an XML file from data that is in our database.
There are clear specifications from the recieving party, and I would like to match my dataset with those specs.

In the specs there are INTEGER field definitions that can have leading zero's. The specific format needed is "99999999"
As we all know, leading zero's have no meaning with Integers so they are cut out without given a format.

So I created a dataset build from temp-tables, filled them with data and used WRITE-XML() to export the XML to a file.

The problem is that the leading zero's are gone in the XML. Even after specifying a format to the temp-table field.
Same story with the Date. The format wasn't changed.

I run Progress 11.7.1

Example Code (Very simplified to show the problem):

Code:
DEFINE TEMP-TABLE ttXmlExample NO-UNDO XML-NODE-NAME 'ExampleXML'
    FIELD Example_code                      AS INTEGER   XML-NODE-TYPE "ELEMENT" XML-NODE-NAME 'Code'       FORMAT "99999999"
    FIELD Example_date                       AS DATE        XML-NODE-TYPE "ELEMENT" XML-NODE-NAME 'StartDate' FORMAT "99-99-9999"
    .

DEFINE DATASET dsXmlExample XML-NODE-TYPE "HIDDEN"
FOR ttXmlExample.

CREATE ttXmlExample.
ASSIGN ttXmlExample.Example_code = 01234567
             ttXmlExample.Example_date = TODAY.

DEF VAR v_xml_example AS HANDLE NO-UNDO.
ASSIGN v_xml_example = DATASET dsXmlExample:HANDLE.

v_xml_example:WRITE-XML("FILE", "test.xml", TRUE, "UTF-8", ?, FALSE, FALSE) NO-ERROR.

This gives the following XML (removed the w3 URL):
XML:
<?xml version="1.0" encoding="UTF-8"?>
<ExampleXML xmlns:xsi="">
  <Code>1234567</Code>
  <StartDate>2022-01-03</StartDate>
</ExampleXML>

It seems that the format is completely ignored while generating the XML. Does anyone know what i'm doing wrong?
Or is it something that can't be helped and should I convert these type of fields to a Character?
I would love to keep the datatypes consistent with the specs.

Thanks in advance.
 
Last edited:

Cecil

19+ years progress programming and still learning.
DEFINE TEMP-TABLE ttXmlExample NO-UNDO XML-NODE-NAME 'ExampleXML'
FIELD Example_code AS CHAR XML-NODE-TYPE "ELEMENT" XML-NODE-NAME 'Code'
FIELD Example_date AS DATE XML-NODE-TYPE "ELEMENT" XML-NODE-NAME 'StartDate' FORMAT "99-99-9999"
.

DEFINE DATASET dsXmlExample XML-NODE-TYPE "HIDDEN"
FOR ttXmlExample.

CREATE ttXmlExample.
ASSIGN ttXmlExample.Example_code = STRING( 01234567, '99999999')
ttXmlExample.Example_date = TODAY.

DEF VAR v_xml_example AS HANDLE NO-UNDO.
ASSIGN v_xml_example = DATASET dsXmlExample:HANDLE.

v_xml_example:WRITE-XML("FILE", "test.xml", TRUE, "UTF-8", ?, FALSE, FALSE) NO-ERROR.
 
Top