WSO2:丰富一个OM属性节点值
WSO2: Enriching a OM property node value
我有一个空的 OM 属性 像这样:
<property description="empty extra_data" name="extra_data" scope="default">
<extra_data xmlns=""/>
</property>
稍后,我想向这个 XML 结构中添加数据。
首先丰富——添加子元素效果很好:
<enrich description="set URL child in extra data">
<source clone="true" type="inline">
<url />
</source>
<target action="child" xpath="$ctx:extra_data"/>
</enrich>
接下来,我要设置存储在另一个属性("url")中的URL。
我已经试过了,但它不起作用(无效目标):
<enrich description="set url" xmlns:ns="http://ws.apache.org/ns/synapse">
<source clone="true" property="url" type="property"/>
<target xpath="$ctx:extra_data//ns:url/text()"/>
</enrich>
有人可以帮我吗? :)
我找到了这个解决方案。在 属性 中设置 XML 标签及其内容,并将其附加为新的子元素。
<property description="url xml tag" expression="fn:concat('<url>', $ctx:url, '</url>')" name="url_xml" scope="default" type="OM"/>
<enrich description="set url child in extra data">
<source clone="true" property="url_xml" type="property"/>
<target action="child" property="extra_data" type="property"/>
</enrich>
我仍然希望在节点内替换或设置一个值,但现在可行...
我有一个空的 OM 属性 像这样:
<property description="empty extra_data" name="extra_data" scope="default">
<extra_data xmlns=""/>
</property>
稍后,我想向这个 XML 结构中添加数据。
首先丰富——添加子元素效果很好:
<enrich description="set URL child in extra data">
<source clone="true" type="inline">
<url />
</source>
<target action="child" xpath="$ctx:extra_data"/>
</enrich>
接下来,我要设置存储在另一个属性("url")中的URL。 我已经试过了,但它不起作用(无效目标):
<enrich description="set url" xmlns:ns="http://ws.apache.org/ns/synapse">
<source clone="true" property="url" type="property"/>
<target xpath="$ctx:extra_data//ns:url/text()"/>
</enrich>
有人可以帮我吗? :)
我找到了这个解决方案。在 属性 中设置 XML 标签及其内容,并将其附加为新的子元素。
<property description="url xml tag" expression="fn:concat('<url>', $ctx:url, '</url>')" name="url_xml" scope="default" type="OM"/>
<enrich description="set url child in extra data">
<source clone="true" property="url_xml" type="property"/>
<target action="child" property="extra_data" type="property"/>
</enrich>
我仍然希望在节点内替换或设置一个值,但现在可行...