Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Simple Transformation serialization - XML has sorted attributes

michelle_fish2
Explorer
0 Likes
1,061

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

3 REPLIES 3
Read only

Former Member
0 Likes
689

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

Read only

michelle_fish2
Explorer
0 Likes
689

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

Read only

michelle_fish2
Explorer
0 Likes
689

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.