如何在Mule中的dataweave中实现嵌套的多级循环

时间:2016-09-28 04:12:35

标签: mule

我正在使用function paralaxCarousel() { var heightStart = $(".carousel .carousel-inner img").height(); // Reset $(".carousel .carousel-inner").css({ "height": heightStart, // 'opacity' : 1-new_opacity }); $(".carousel-caption").css({ "top": 0 }); $(window).unbind('scroll').scroll(function(e) { var scrollTopPosition = $(window).scrollTop(); // Change the height of the carousel inner. $(".carousel .carousel-inner").css({ "height": heightStart - scrollTopPosition, 'opacity' : 1 - scrollTopPosition / 1000 }); // Change the position of the caption. $(".carousel-caption").css({ "top": - scrollTopPosition / 2 }); }); } $(window).resize(function(){ paralaxCarousel(); }); paralaxCarousel(); 将XML转换为CSV。我想知道如何在dataweave中实现嵌套for循环。

以下是输入xml:

dataweave

例外输出:

 <employee>
  <id>1236</id>
  <emplinfo>
     <emplid>1961</emplid>
     <jobinfo>
        <status>T</status>
        <title>Manager</title>
        <start_date>2016-09-01</start_date>                        
     </jobinfo>
     <jobinfo>
        <status>P</status>
        <end_date>2016-08-31</end_date>
        <title>Integration Manager</title>
        <start_date>2016-08-01</start_date>
     </jobinfo>
     <jobinfo>
        <status>A</status>
        <end_date>2016-07-31</end_date>
        <title>Communications Manager</title>
        <start_date>2016-07-17</start_date>
     </jobinfo>
  </emplinfo>
  <emplinfo>
     <emplid>1801</emplid>
     <jobinfo>
        <status>T</status>
        <title>AM</title>
        <start_date>2016-09-01</start_date>                        
     </jobinfo>
  </emplinfo>
 </employee>

非常感谢任何帮助。

2 个答案:

答案 0 :(得分:1)

这对我有用。

%dw 1.0
%output application/csv
---
flatten (payload map ((parent, parentindex) -> {
    emplinfo:(parent.*emplinfo map ((emplinfo,empindex) -> {
        jobinfo:(emplinfo.*jobinfo map ((jobinfo,jobindex) -> {
            id: parent.id,
            emplid : emplinfo.emplid,
            status: jobinfo.status,
            end_date:jobinfo.end_date,
            title:jobinfo.title,
            start_date:jobinfo.start_date
        }))
    }))
}))..jobinfo

我使用过普通的csv。你可以选择任何一种格式。输出

id,emplid,status,end_date,title,start_date
1236,1961,T,,Manager,2016-09-01
1236,1961,P,2016-08-31,Integration Manager,2016-08-01
1236,1961,A,2016-07-31,Communications Manager,2016-07-17
1236,1801,T,,AM,2016-09-01

希望这有帮助。

答案 1 :(得分:0)

做这样的事情

Segment:(payload.segments map ((segment, segmentIndex)->
    {
        Leg:(segment.legs map ((leg, legIndex)->
            {                   
                Origin:leg.departureField.airportCodeField,
                Destination:leg.arrivalField.airportCodeField
            }))
    }))