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

MuleSoft error
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

  1. Add an explicit output directive to the script.
  2. For a plain value, use the docs' form: output text/plain --- payload.order.product.model.
  3. If you do want XML, return an object with a single root element.

04Official documentation

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

The iPaaS Brief

Subscribe to The iPaaS Brief.

The iPaaS newsletter for the people who run integrations. From iPaaS Group.

Free. You finish on theipaasbrief.com and confirm by email.