【发布时间】:2015-10-21 07:00:44
【问题描述】:
我正在使用 WSO2 ESB 4.8.1,我想使用 xslt 修改 soap 消息。
我的肥皂信息:
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:getResponse xmlns:ns2="http://nis.ayss.com.tr/">
<return>
<result>true</result>
<responseList>
<name>STACK</name>
<number>001</number>
</responseList>
</return>
</ns2:getResponse>
</S:Body>
</S:Envelope>
我想将“名称”元素更改为“品牌”,并将此消息修改如下:
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:getResponse xmlns:ns2="http://nis.ayss.com.tr/">
<return>
<result>true</result>
<responseList>
<brand>STACK</brand>
<number>001</number>
</responseList>
</return>
</ns2:getResponse>
</S:Body>
</S:Envelope>
XSLT:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns2="http://nis.ayss.com.tr/">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="name">
<brand>
<xsl:apply-templates select="@*|node()"/>
</brand>
</xsl:template>
</xsl:stylesheet>
我在 WSO2 ESB 中创建了一个 xslt 文件作为本地条目。但是它将默认命名空间添加为 xmlns="http://ws.apache.org/ns/synapse" 并将 xslt 更改为:
<xsl:template match="name">
<brand xmlns="http://ws.apache.org/ns/synapse">
<xsl:apply-templates select="@*|node()"/>
</brand>
</xsl:template>
所以我的结果肥皂信息是:
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:getResponse xmlns:ns2="http://nis.ayss.com.tr/">
<return>
<result>true</result>
<responseList>
<brand xmlns="http://ws.apache.org/ns/synapse">STACK</brand>
<number>001</number>
</responseList>
</return>
</ns2:getResponse>
</S:Body>
</S:Envelope>
如何在 WSO2 ESB 中使用 XSLT 在不添加命名空间的情况下修改此元素名称?
【问题讨论】:
标签: xslt soap wso2 wso2esb esb