Skip to Content
author's profile photo Former Member
Former Member

Simple Transformation for a file with a changing order of tags

Hi,

I am trying to write a transformation for an XML file but i'm facing a problem:

The order of the tags of the XML is random.

for example:

the XML can look like so:

<person>

<name>Bob</name>

<lastname>Green</lastname>

<country>Italy</country>

</person>

and also like so:

<person>

<country>Italy</country>

<lastname>Green</lastname>

<name>Bob</name>

</person>

How can I write a transformation that works no matter how the tags are ordered?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 11, 2016 at 05:36 PM

    Hi Mezamer,

    If you cannot guarantee the order of the incoming xml then i would recommend having a buffer program put in place that can read the incoming xml and rearrange it into the proper order and then send it to the transformation.

    You could use a FM like text_convert_xml_to_sap and then use a loop to create a new xml. This thread may also be useful since it seems like they are doing something similar

    Hope this helps,

    Geoffery

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 14, 2016 at 10:19 AM

    Hi,

    In my opinion, ordering of tags while creating XML with XSLT tool should not be problem its attributes may have the issue but not the tag order.

    Could you please provide me the small snippet of sample code, so that I can check and provide my further inputs on this.

    Best Regards,
    Ayush

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.