‎2010 Mar 10 8:57 PM
Hello. I am trying to call a Simple transformation (serialization (internal table to XML)) process from an ABAP program and the resulting XML has the attributes sorted.
My question is: If I need the XML output to have a certain order to the attributes - how do I remove the sorting ?
ABAP program has this table defined:
data: begin of wa_final_xml,
act type string,
col1 type string,
col2 type string,
col10 type string,
end of wa_final_xml.
The Simple transformation mapping is like this:
<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
<tt:root name="T_FINAL_XML"/>
<tt:template>
<tt:loop ref="T_FINAL_XML">
<z:row>
<tt:attribute name="action" value-ref="ACT"/>
<tt:attribute name="column1" value-ref="COL1"/>
<tt:attribute name="column2" value-ref="COL2"/>
<tt:attribute name="column10" value-ref="COL10"/>
</z:row>
</tt:loop>
</tt:template>
</tt:transform>
The XML output is below (as you can see the attribute column10 is before column2. I need column2 to be before column10).
<z:row action="1" column1="Dept1" column10="changed on 03-09-2010" column2="UC01"/>
<z:row action="1" column1="Dept2" column10="changed on 03-09-2010" column2="UC02"/>
Help would be appreciated.
Thanks, Michelle
‎2010 Mar 11 12:10 AM
Hi,
I created new transformation (copied from yours) and simple program which uses this transformation,
it gives correct result - and I can get columns in any order I set in XSL.
If you still have the problem, please send whole program and XSL file.
Regards,
--
Przemysław
‎2010 Mar 11 4:11 PM
I am still getting the problem.
I've sent you the whole program, the input file and the output file that is being generated.
Michelle
‎2010 Mar 23 9:07 PM
I entered an OSS message and they responded that I should not be worried that the attributes
are sorted and not in the order that the vendor requested.
=========OSS Response below========================
you are right, that in your example the attributes are sorted. In the
W3C XML specification it is defined, that XML attributes or not ordered.
This means, that an XML parser can not expect ordered XML attributes.
The sorted order of the attributes in your example is because of the
implementation details of the iXML library. In addition to that the
order of attributes is not guaranteed and can differ depending on the
XML technology and release version you are currently using.
I hope this information helps you to understand that you have to
implement you XML applications in the way to be prepared for attributes
in random order.