I am using DocumentConvertor#convertDocumentToXML() to transform some IDocuments into XMLs.
In those XMLs I noticed, that the order of the elements is sometimes weird. I expected the elements to be either in alphabetical order or in the order of the fields in the document model, but the actual order is somehow different. For some XML-transformation that are planned later on I need to be certain of the order of the elements.
So my questions are:
- How is the order of the elements in the XML determined? Or is it kind of random?
- Can I maybe influence the order?
I hope somebody can give me some answers, as I did not find the necessary informations on getA12
Hi @tim-steep-bit,
We delegate serialization and deserialization to Kernel that has API for it.
IDocumentSerializer#serialize(document, w, DocumentSerializationConfig.builder()
.format(DocumentSerializationConfig.Format.XML)
.skipTransientFields(!persistTransient)
.build());`
, where Writer w
I will ask my colleagues from Kernel team to answer your question.
Hi @tim-steep-bit,
the Kernel API used by DS considers neither alphabetical sorting nor according to the order of fields in the document model. At the moment, the order of the fields depends on the order which is delivered in IDocument#getEntityInstances() (Set). As far as I know, DS uses the Kernel implementation of IDocument which means that the field order of the serialized document in JSON format should be the order of the serialized document in XML format.