wso2 - wso2 foreach 循环永远不会进入
问题描述
我正在尝试让 wso2 foreach 循环工作。
<property expression="$ctx:xmlTransform"
$ctx:xmlTransform 的值:
<magasin>
<codeMagasin>20019</codeMagasin>
</magasin>
<magasin>
<codeMagasin>20020</codeMagasin>
</magasin>
<magasin>
<codeMagasin>20021</codeMagasin>
</magasin>
环形 :
<foreach expression="$ctx:xmlTransform//magasin" xmlns:ns="http://org.apache.synapse/xsd">
<sequence>
<log category="ERROR">
<property expression="tessst" name="----Test foreach loop----"/>
</log>
</sequence>
</foreach>
我永远不会进入循环。
有任何想法吗 ?非常感谢。
解决方案
也许问题在于“magasin”节点没有包含在一个父元素中。尝试用一些父元素(例如框)包装它,用父元素替换body,然后运行循环。
<enrich>
<source type="inline" clone="true">
<ns:box xmlns:ns="http://namespace"/>
</source>
<target type="property" property="box"/>
</enrich>
<enrich>
<source clone="true" xpath="$ctx:xmlTransform"/>
<target action="child" xpath="$ctx:box"/>
</enrich>
<enrich>
<source type="property" clone="true" property="box"/>
<target action="replace" type="body"/>
</enrich>
<foreach expression="//ns:box/magasin" xmlns:ns="http://namespace">
<sequence>
<log category="ERROR">
<property expression="tessst" name="----Test foreach loop----"/>
</log>
</sequence>
</foreach>
推荐阅读
- java - 模拟静态方法+运行参数化测试=“找不到匹配”
- java - Spring + Mongodb 与 Null id 问题
- python - 这个 f 在 python 中来自哪里。因子计算器
- runtime - 我收到一条错误消息,显示 MIPS:第 27 行:0x0040003c 处的运行时异常:地址超出范围 0x00000000。不太明白为什么
- c++ - 返回类型与自动的模板特化和显式规范
- html - 无法垂直对齐内联块 div
- python - 如何在 Pandas 中创建滑动数据框
- windows - 如何通过批处理文件移动文件但如果文件已经存在移动到其他地方?
- javascript - HTML 视频右键上下文菜单 - 仅隐藏循环和显示控件
- regex - AWK 将任务列表中的字符串日期值与今天的日期进行比较