MuleSoft · DataWeave
Trying to output non-whitespace characters outside main element tree
Short answer
This DataWeave error means the script's output was inferred as XML, but the value it returns is not a valid XML document. Declare the output format you really want, for example output text/plain.
VerifiedLast verified
01Error text
Trying to output non-whitespace characters outside main element tree (in prolog or epilog), while writing Xml at .02Likely causes
- The script has no explicit output format, so the output was inferred as XML.
- The script returns a plain value, which cannot be written as an XML document.
03How to fix it
- Add an explicit output directive to the script.
- For a plain value, use the docs' form:
output text/plain --- payload.order.product.model. - If you do want XML, return an object with a single root element.
04Official documentation
→Related errors
- Text plain writer is unable to write ArrayText plain writer is unable to write Array means the script has no output format, so DataWeave inferred plain text and cannot write the array the script returns. Declare an output format that supports arrays.
- MULE:EXPRESSIONMULE:EXPRESSION means an error occurred while Mule evaluated a DataWeave expression. Find the expression named in the log, check the values it reads for nulls or wrong types, and add a default or a handler.
Test every fix in a non-production environment before you apply it to production. See how entries are verified.
More for MuleSoft work:Open MuleSoft jobsMuleSoft rates and salariesHire a senior MuleSoft developer