Issue 31622  —   xmltostruct/schema does not convert attributes of non-string elements

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 an XML file using xmlToStruct/schema then attributes of
 non-string elements are not converted. The problem does not occur when
 converting XML without a schema using xmlToStruct.

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

 +Operating System:
 * OS independent

 +Database:
 * DBMS independent

 Symptoms:
 When converting an XML file using xmlToStruct/schema then attributes of
 non-string elements are not converted. The problem does not occur when
 converting XML without a schema using xmlToStruct.

 Consider the following code:

 variables
         string vXml, vXsd
         struct vStruct
 endvariables

 putmess "*** xmlToStruct ***"
 putmess " "

 vStruct = ""

 xmlToStruct vStruct, $xml1
 putmess vStruct->$dbgstringplain

 putmess " "
 putmess "*** xmlToStruct/schema ***"
 putmess " "

 vStruct = ""

 lfiledump $xsd1, "test.xsd"

 xmlToStruct/schema vStruct, $xml1, "test.xsd"

 return(0)

 xml1:blockdata ~
 <root>
 <Element1 Att="AttributeText">T12345</Element1>
 <Element2 Att="AttributeText">12345</Element2>
 <Element3 Att="AttributeText">123.45</Element3>
 <Element4 Att="AttributeText">2017-06-22</Element4>
 </root>
 ~

 xsd1:blockdata ~
 <?xml version="1.0" encoding="UTF-8"?>
 <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified"
 xmlns:xs="http://www.w3.org/2001/XMLSchema">
   <xs:element name="root" type="rootType"/>
   <xs:complexType name="Element1Type">
     <xs:simpleContent>
       <xs:extension base="xs:string">
         <xs:attribute type="xs:string" name="Att"/>
       </xs:extension>
     </xs:simpleContent>
   </xs:complexType>
   <xs:complexType name="Element2Type">
     <xs:simpleContent>
       <xs:extension base="xs:short">
         <xs:attribute type="xs:string" name="Att"/>
       </xs:extension>
     </xs:simpleContent>
   </xs:complexType>
   <xs:complexType name="Element3Type">
     <xs:simpleContent>
       <xs:extension base="xs:float">
         <xs:attribute type="xs:string" name="Att"/>
       </xs:extension>
     </xs:simpleContent>
   </xs:complexType>
   <xs:complexType name="Element4Type">
     <xs:simpleContent>
       <xs:extension base="xs:date">
         <xs:attribute type="xs:string" name="Att"/>
       </xs:extension>
     </xs:simpleContent>
   </xs:complexType>
   <xs:complexType name="rootType">
     <xs:sequence>
       <xs:element type="Element1Type" name="Element1"/>
       <xs:element type="Element2Type" name="Element2"/>
       <xs:element type="Element3Type" name="Element3"/>
       <xs:element type="Element4Type" name="Element4"/>
     </xs:sequence>
   </xs:complexType>
 </xs:schema>
 ~

 When executing the abov code then te result is:

 *** xmlToStruct ***

 []
   [root]
     [Element1]
       [Att] = "AttributeText"
       "T12345"
     [Element2]
       [Att] = "AttributeText"
       "12345"
     [Element3]
       [Att] = "AttributeText"
       "123.45"
     [Element4]
       [Att] = "AttributeText"
       "2017-06-22"

 *** xmlToStruct/schema ***

 []
   [root]
     [Element1]
       [Att] = "AttributeText"
       "T12345"
     [Element2] = 12345
     [Element3] = 123.45
     [Element4] = 20170622

 => The attribute Att of the non-string elements Element2, Element3 and Element4
 is missing when using xmlToStruct/schema.

Workaround:

 There is no known workaround for this problem.

Notes: