I am trying to filter my payload by applying a filter on a date range. Unfortunately, I don't think it works as the data return is invalid. Can you guys help me to check on the cause for this mistake? fyi I already coerce the date data as localdatetime respectively.
Variable
sessionVars.DateFrom = 2017-05-01T00:00:00
sessionVars.DateTo = 2017-09-01T23:59:59
Current Input
<GetListOfCategoriesDetailResponse xmlns="" xmlns:s="">
<GetListOfCategoriesDetailResult xmlns:a="" xmlns:i="">
<a:CategoryDetail>
<a:CategoryCode>ABC456</a:CategoryCode>
<a:Arrive>2017-12-14T15:00:00</a:Arrive>
<a:Depart>2018-01-10T15:00:00</a:Depart>
</a:CategoryDetail>
<a:CategoryDetail>
<a:CategoryCode>ABC123</a:CategoryCode>
<a:Arrive>2017-08-14T15:00:00</a:Arrive>
<a:Depart>2017-08-20T15:00:00</a:Depart>
</a:CategoryDetail>
<a:CategoryDetail>
<a:CategoryCode>BCD344</a:CategoryCode>
<a:Arrive>2017-05-14T15:00:00</a:Arrive>
<a:Depart>2017-06-01T15:00:00</a:Depart>
</a:CategoryDetail>
</GetListOfCategoriesDetailResult>
</GetListOfCategoriesDetailResponse>
Expected Output
<ns0:FoodProducts>
<ns0:FoodProduct>
<ns0:FruitTypes>
<ns0:FruitType FruitTypeCode="ABC123">
</ns0:FruitType>
<ns0:FruitType FruitTypeCode="BCD344" >
</ns0:FruitType>
</ns0:FoodProduct>
</ns0:FoodProducts>
My thus far dataweave code
%output application/xml
%namespace ns0
%namespace ns01
%namespace ns1
---
{
ns0#FoodProductRS: {
ns0#FoodProducts: {
ns0#FoodProduct: {
ns0#FruitTypes: {
(payload.ns01#GetListOfCategoriesDetailResponse.ns01#GetListOfCategoriesDetailResult.*ns1#CategoryDetail filter (sessionVars.DateTo as :localdatetime {format:"yyyy-MM-dd'T'HH:mm:ss"}) >= ($.Arrive as :localdatetime {format:"yyyy-MM-dd'T'HH:mm:ss"})
and (sessionVars.DateFrom as :localdatetime {format:"yyyy-MM-dd'T'HH:mm:ss"}) <= ($.Depart as :localdatetime {format:"yyyy-MM-dd'T'HH:mm:ss"})
map ((categoryDetail , indexOfCategoryDetail) -> {
ns0#FruitType @(FruitTypeCode: categoryDetail.ns1#CategoryCode)
}))
}
}
}
}
}