Which statement best describes what happens when DataWeave attempts to output XML from a payload that is a simple map without a single root key?

Study for the MuleSoft Associate / Development Fundamental Test. Master key concepts with flashcards and multiple choice questions, complete with hints and explanations. Prepare thoroughly for your exam!

Multiple Choice

Which statement best describes what happens when DataWeave attempts to output XML from a payload that is a simple map without a single root key?

Explanation:
XML documents must have a single root element, so when DataWeave is asked to output XML, it needs one top-level key to serve as that root. If the payload is just a simple map with multiple keys and no single root key, there’s no single element to anchor the entire XML document, and this results in an error. To produce XML from such data, wrap the payload with a single root key in the transformation, for example: output application/xml --- { root: payload }. This creates a well-formed XML document with a single root element. The other options aren’t correct because there isn’t a default root element, XML isn’t automatically wrapped or converted into JSON inside an XML tag, and DataWeave will not silently produce no XML—it will raise an exception instead unless you explicitly provide a root wrapper.

XML documents must have a single root element, so when DataWeave is asked to output XML, it needs one top-level key to serve as that root. If the payload is just a simple map with multiple keys and no single root key, there’s no single element to anchor the entire XML document, and this results in an error. To produce XML from such data, wrap the payload with a single root key in the transformation, for example: output application/xml --- { root: payload }. This creates a well-formed XML document with a single root element. The other options aren’t correct because there isn’t a default root element, XML isn’t automatically wrapped or converted into JSON inside an XML tag, and DataWeave will not silently produce no XML—it will raise an exception instead unless you explicitly provide a root wrapper.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy