更改 ESB 中的 xml 节点名称

Rez*_*eri 0 xslt esb wso2 wso2-esb

我想更改 WSO2 ESB 中的 xml 节点名称,即。我有以下 xml

<MessageStatus xmlns="foo.example.org">
<ErrorCode>$1</ErrorCode>
<Message>$2</Message>
</MessageStatus>

我希望它是这样的

<ItemName xmlns="foo.example.org">
<ErrorCode>$1</ErrorCode>
<Message>$2</Message>
</ItemName>

以 ItemNames 作为属性;我的意思是它们会动态变化。有什么方法可以使用 ESB 中介器进行此更改吗?

Rez*_*eri 5

最后我使用 XSLT Mediator 完成了此操作,我的 Mediator 配置如下:

<xslt xmlns="http://ws.apache.org/ns/synapse" key="conf:/users/UsersXSLT.xslt">
   <property xmlns:ns="http://org.apache.synapse/xsd" name="TagName" expression="concat(get-property('OperationName'),'Response')"/>
</xslt>
Run Code Online (Sandbox Code Playgroud)

我为其定义了一个属性,可以在 XSLT 转换中使用它。我的 XSLT 是:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fn="http://www.w3.org/2005/02/xpath-functions"
xmlns="http://www.jdnasir.ac.ir/EMI/UserProxy/"
exclude-result-prefixes="fn">
<xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>

<xsl:template match="/">
<xsl:apply-templates />
</xsl:template>
<xsl:param name="TagName"/>
<xsl:template match="MessageStatus">
<xsl:element name="{$TagName}" xmlns="http://www.jdnasir.ac.ir/EMI/UserProxy/">
<xsl:for-each select="/MessageStatus/*">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:for-each>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
Run Code Online (Sandbox Code Playgroud)

这个 xslt 的棘手部分是这<xsl:element name="{$TagName}"部分。

我希望这会帮助其他人。