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

Status:   Planned for resolution in 10.4.01

Solution available in patch(es):


 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.

 * Version 9.6.01 (and higher)

 +Operating System:
 * OS independent

 * DBMS independent

 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:

       [attribute1] = "String"
           [xmlClass] = "attribute"
       [attribute1] = 20180703
           [xmlClass] = "attribute"

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

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

 > Expected result:

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


 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], "-",
 vStruct->root->element2->attribute1 = vStringDate
 structToXml/schema vXml, vStruct, "mySchema.xsd"