MCD - Level 1 Exam QuestionsBrowse all questions from this exam

MCD - Level 1 Exam - Question 86


Refer to the exhibit.

What DataWeave expression transforms the conductorIds array to the XML output?

A.

B.

C.

D.

Show Answer
Correct Answer:

The DataWeave expression required to transform the `conductorIds` array to the provided XML output needs to wrap the transformation result in curly braces to ensure it is interpreted correctly. The correct expression is: ``` trains: { conductorIds map ( (engId, index) -> train: { engineerId: engId } ) } ``` This structure correctly generates the XML as shown in the exhibit, making Option B the correct answer. The other options either have incorrect parentheses or do not correctly define the required structure.

Discussion

5 comments
Sign in to comment
pgarciar
Mar 29, 2021

B is correct

Zumo
May 29, 2021

Option D gives below Error in Runtime. ""Trying to output second root, <trains>, while writing Xml at ." evaluating expression: "%dw 2.0 output application/xml var conductorIds=[592,251] --- trains: conductorIds map ( (engId, index) -> train: { engineerId: engId } ) ------------------------------------------- So the Correct Answer would be Option B.

Empire
Apr 10, 2022

yes bro you are right.. even i also tried this expression : var conductorIds=[592,251] --- trains: conductorIds map ( (engId, index) -> train: { engineerId: engId } ) i am getting error.. so, i tried this .. trains: {( conductorIds map ( (engId, index) -> train: { engineerId: engId } ) )} it is working fine ... correct option is "B"....

miguel_romero
Dec 15, 2021

B is correct

Gaurav_9412
Jul 15, 2023

B is correct %dw 2.0 var conductorIds=[10,30] output application/xml // imports modules::Utility // fun productcategory(itemId : Number,productcategory :String) = // "PC-"++ productcategory ++ (itemId as String) import dw::core::Strings --- // payload map (( key, index) -> ) // trains :{ // conductorIds map ((item,index)-> train:{ // }) // } // typeOf(payload) // { 'plural': Strings::pluralize("box") } trains :{ (conductorIds map ((item, index) -> { 'train' : { "engineerId":item, }})) }

ExamDev
Jan 22, 2024

The correct answer is B: Tested on the anypoint studio output application/xml var conductorIds=[592,251] --- trains: { (conductorIds map ( (engId, index) -> train: { engineerId: engId } )) }