I am trying to transform a JSON payload that has no set ordering to an XML payload that is defined by an XSD schema. Is there any DataWeave script or function that can dynamically map elements to conform to that XSD? In essence my JSON payload has the same structure of the SOAP body that I have but there might be chances that the ordering of elements in the JSON request may be out of order.
For example: JSON input:
{
"ConcatenateRequest":
{
"string2": "World",
"string1": "Hello"
}
}
XML output after transformation:
<ConcatenateRequest>
<string1>Hello</string1>
<string2>World</string2>
</ConcatenateRequest>
assuming that the order/schema has string1 appear before string2
This dataweave contains two ways of ordering: One is by the value the other one by key. Both result in the same output but that is due to the coincidence in the data provided.