I have an Application/Java ArrayList. That contains XML elements in String format. I want to add to a main/root node with Dataweave 2:
%dw 2.0
output application/xml
---
shops: write(vars.shop, "application/xml")
But it returns:
Caused by:
javax.xml.stream.XMLStreamException: Trying to write END_DOCUMENT when document has no root (ie. trying to output empty document)
How can I solved that? I tried with application/java but still failing, the problem is into the write() method trying to transform the array to XML.
What does the vars.shop has? Most commonly for xml building you need to use the dynamic object feature.
This script outputs