OL Learn

Sort XML Records

Is it possible to sort records in the data mapper (XML Data) based on a field in the record?
The data would have a few detail tables in each record.

If possible then is also possible to sort a second level?
Such by State and then within the State by County.

You could do it in Workflow using the XSLT plugin, provided that you understand XSLT syntax.
If you want to do it in the Datamapper, IT can be done in the Preprocessor using a script.

I do it for JSON data which is a lot easier. You could as well convert your XML data to a JSON format and then do the sorting in the Datamapper

Find attached a Datamapper example of JSON sorting on 2 fields. It was done in Connect 2021.2.1. It was initially a XMLfile that I converted to JSON format using the XML/JSON Conversion plugin in Workflow.

Simply look at the result in the Datamodel. Notice the order of the 5 records based on the extraction if Country and State.

Then go in the Preprocessor’s script, tick the checkbox next to it and click on the green arrow on the right side.

Then go back to check the new order of the records.

Note that in my example, the sorting is done on the JSON objects inside of a array.

sortJSON2Level.OL-datamapper (5.8 KB)

The process uses a datamapper to extracts only the necessary fields from a large xml file. Takes around 30 minutes to output the new XML file which is then processed with another datamapper.

After switching output to JSON instead of XML, I get an Out of Memory error.

image

This is on 2021.1 with 8GB Ram and also with 16GB Ram. Also increased engine memory from the default settings.

image

At this point, I suggest you open a technical support ticket through our website.