Issue 31817  —   structToXml/schema: non-string attributes are treated as strings

Status:   Planned for resolution in 10.4.01

Solution available in patch(es):      10.3.01.003    9.7.05.003

Description:

 Summary:
 When converting a Struct to XML using a schema (structToXml/schema) then
 non-string attributes (e.g. dates) are not converted correctly. Instead of
 being encoded using the specified data type (e.g. xs:date) the value is encided
 as a plain string.

 Environment:
 +Uniface:
 * Version 9.6.01 (and higher)

 +Operating System:
 * OS independent

 +Database:
 * DBMS independent

 Symptoms:
 A Struct can be converted to an XML document that conforms to a schema (using
 the xmlToStruct/schema statement). In case the Struct includes an attribute
 that is defined in the schema as a non-string (e.g. a date) then in the
 generated XML the value is just a plain string (showing e.g. the internal date
 value of Uniface).

 For example:

 > This is the source Struct:

 []
   [root]
     [element1]
       [attribute1] = "String"
         [$tags]
           [xmlClass] = "attribute"
       "String"
     [element2]
       [attribute1] = 20180703
         [$tags]
           [xmlClass] = "attribute"
       20180703

 > And here's the XML generated by xmlToStruct/schema:

 <root>
 <element1 attribute1="String">String</element1>
 <element2 attribute1="20180628">2018-06-28</element2>
 </root>

 > Expected result:

 <root>
 <element1 attribute1="String">String</element1>
 <element2 attribute1="2018-06-28">2018-06-28</element2>
 </root>

Workaround:

 The values of non-string attributes need to be converted to the target format
 before using xmlToStruct/schema. E.g.
 
 vStringDate = $date
 vStringDate = $concat(vStringDate[1:4], "-", vStringDate[5:2], "-",
 vStringDate[7:2])
 vStruct->root->element2->attribute1 = vStringDate
 structToXml/schema vXml, vStruct, "mySchema.xsd"

Notes: