Exam MCD - Level 1 All QuestionsBrowse all questions from this exam
Question 86

Refer to the exhibit.

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

A.

B.

C.

D.

    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
pgarciar

B is correct

Zumo

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

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"....

ExamDev

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 } )) }

Gaurav_9412

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, }})) }

miguel_romero

B is correct