【发布时间】:2021-03-10 05:40:31
【问题描述】:
我想在 Mule 4 的 Dataweave 2.0 中检查以下 XML 中是否存在 <price-adjustments> 标签。如何实现?
我在下面尝试,但它给了我语法错误:
(payload.ns0#order.ns0#"product-lineitems".*ns0#"product-lineitem" map( e , lineindex ) -> {
if(e.price-adjustments != null || e.price-adjustments != "") e."price-adjustments"."base-price" - (e."price-adjustments"."tax"/e."price-adjustments".quantity") else e.ns0#"base-price" - (e.ns0#"tax"/e.ns0#"quantity")
}
XML
<?xml version="1.0" encoding="UTF-8"?>
<order xmlns="http://www.demandware.com/xml/impex/order/2006-10-31" version="20.8" order-no="00002404">
<order-date>2021-03-08T15:20:32.084Z</order-date>
<product-lineitems>
<product-lineitem>
<net-price>487.60</net-price>
</product-lineitem>
<product-lineitem>
<net-price>53.72</net-price>
<price-adjustments>
<price-adjustment>
<net-price>-53.72</net-price>
</price-adjustment>
</price-adjustments>
</product-lineitem>
</product-lineitems>
</order>
【问题讨论】:
-
您是要检查任何产品线中是否存在价格调整,还是需要检查每个产品线中是否存在上述字段?
-
针对每个产品系列