我有一个应用程序/Java ArrayList。它包含 String 格式的 XML 元素。我想使用 Dataweave 2 添加到主/根节点:
%dw 2.0
output application/xml
---
shops: write(vars.shop, "application/xml")
但它返回:
Caused by:
javax.xml.stream.XMLStreamException: Trying to write END_DOCUMENT when document has no root (ie. trying to output empty document)
我该如何解决?我尝试使用 application/java 但仍然失败,问题在于 write() 方法试图将数组转换为 XML。