Which of the following is a valid XML root expression when using DataWeave 1.0 with output application/xml?

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 of the following is a valid XML root expression when using DataWeave 1.0 with output application/xml?

Explanation:
DataWeave 1.0 XML output requires a single root element, defined by the top-level key followed by a colon and a map of its children. The structure rootName: { ... } tells DataWeave to create an XML document with a root element named rootName, whose child elements come from the keys inside the nested map. In this example, using user as the root yields a single <user> element containing <fname>John</fname> and <lname>Doe</lname>, which is a valid XML with one root. The other forms would not produce a single root element. If you had multiple top-level keys, you’d end up with multiple root elements, which XML does not allow. A literal XML string shown is not the DW root expression that generates XML from a data structure.

DataWeave 1.0 XML output requires a single root element, defined by the top-level key followed by a colon and a map of its children. The structure rootName: { ... } tells DataWeave to create an XML document with a root element named rootName, whose child elements come from the keys inside the nested map. In this example, using user as the root yields a single element containing John and Doe, which is a valid XML with one root.

The other forms would not produce a single root element. If you had multiple top-level keys, you’d end up with multiple root elements, which XML does not allow. A literal XML string shown is not the DW root expression that generates XML from a data structure.

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy