我試圖提取類別-ID時初級=真通過產品ID的分組騾Dataweave對象到陣列誤差
%input payload application/xml
%output application/java
---
using (c=payload.catalog.*category-assignment default [])
((c default []) filter ([email protected] != "delete") groupBy [email protected] map ({
(($ default []) filter ($.primary == 'true') map ({
field3:[email protected]
}) when $.primary != null otherwise field3:""),
cat-id: [email protected] joinBy "||" ,
primary-flag:$.primary
// (($ default []) filter ($.primary matches /true/) map ({
// //ur code here when equals to shipping charges
// field3:[email protected]
// }) when $.primary != null otherwise []) ,
}))
我與多個組合和過濾器嘗試。過濾器通常使用XML屬性的作品,但這裏給人異常
cast to com.mulesoft.weave.model.structure.ObjectSeq (java.lang.ClassCastException). Message payload is of type: ReceiverFileInputStream
樣品輸入 -
<?xml version="1.0" encoding="UTF-8"?>
<catalog xmlns="http://www.example.com/xml/impex/catalog/2006-10-31">
<category-assignment product-id="D711069" category-id="4160">
<primary>true</primary>
</category-assignment>
<category-assignment product-id="D711069" category-id="DANIEL_4160"/>
</catalog>
任何這裏建議?
我嘗試另一套改造只是爲了演示,不工作 -
%input payload application/xml
%output application/xml
---
Test:{((payload.catalog.*category-assignment default []) groupBy [email protected] pluck {
product-id:$$,
cat-id: [email protected] joinBy "||" ,
primary-flag:$[0].primary,
field3:[email protected][?($.primary == "true")]
})}
我想創建CSV,FIELD1 =類別-ID,字段2 =產品-id(產品分組),field3 =當primary = true時的category-id –
按照上面的xml,csv應該看起來像D711069,4160 || DANIEL_4160,4160我們需要使用||加入類別 –
上面的代碼適用於單個節點 true category-assignment>,但每當我傳遞多個節點時,其給出的錯誤 –