DTL Transformation output: ordering of XML nodes
We are using a DTL transformation to take HL7 and transform into custom XML. But the nodes in the resulting XML are appearing out of sequence - and therefore failing validation against the schema.
The XSD schema for the XML looks fine when imported into Ensemble: root node in the XSD looks like this:.png)
And shows in Ensemble like this:.png)
The transformation looks like this, and we can see the text from the trace elements at lines 5, 12 and 19 appear in the correct order in the event log:
.png)
HOWEVER, the resulting XML has the <allergies> nodes before the <patientNotes> nodes....:
.png)
Any ideas about why this is happening, and how we can ensure nodes are generated in the correct order?
Comments
Additional info: if we change the order of <allergies> and <patientNotes> in the schema, it does not change the order of elements produced in the XML.
Can you provide more details on how the target class used in the DTL is defined?
Its a virtual document: EnsLib.EDI.XML.Document, with the XML schema applied having been loaded into Ensemble via Ensemble -> InterOperate -> XML -> XML Schema Structures.
.png)
Note that this issue arises in a transformation we are also having other, we suspect unrelated issues with, discussed here: DTL Transformation output: maxOccurs bug? | InterSystems Developer
With help from WRC, looks like this is something of our own doing - we were using sub-transforms in ways that caused us problems. Our sub-transforms above were outputting whole new XML documents, when at the very least they should have been taking existing partially produced XML from the top-level transform and using that existing document to output. We "solved" the node ordering issue by moving everything into a single transform, so there was no mismatch between top level and sub-transforms.