Data weaver looping and checking nullify using ESB mule -


i tried implement simple loop checking null variable , setting in result.

my portion of mule flow looks below.

database(select) -> transform message(dataweave- convert xml)

database has value below :

book1 book2 book3 book4 book5 abc   cde   fgh   ijk   lmn opq   rst   null  null  null 

dataweaver code looks below :

ns0#librarydetails:{                 ns0#user: payload."book1",                 ns0#user: payload."book2",                 ns0#user: payload."book3",                 ns0#user: payload."book4",                 ns0#user: payload."book5"             } 

expected output1 is

<librarydetails>    <user>abc</user>    <user>cde</user>    <user>fgh</user>    <user>ijk</user>    <user>lmn</user> </librarydetails> 

expected output2 is

<librarydetails>    <user>opq</user>    <user>rst</user> </librarydetails> 

how can escape null values , creating loop in data weave. tried map function well. please show light on this.

to expected output use map , use skipnullon="everywhere" if want logic across elements. following gives me expected output

%dw 1.0     %output application/xml skipnullon="everywhere"      %namespace ns0 http://something.com     ---      ns0#librarydetails: { (payload map {           ns0#user: $.book1,           ns0#user: $.book2,           ns0#user: $.book3,           ns0#user: $.book4,           ns0#user: $.book5     } )  } 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -