XSLT 删除 SOAP 信封但保留名称空间 [英] XSLT to remove SOAP envelope but leave namespaces
本文介绍了XSLT 删除 SOAP 信封但保留名称空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要从soap消息中取出soap信封.为此,我想使用 XSLT,而不是 java.操作这种类型的xml会是更合适的解决方案.
I need to remove soap envelope from soap message. For that I want to use XSLT, not java. It would be more proper solution for operating such type of xml.
例如我有一条肥皂消息:
For e.g. I have a soap message:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:tar="namespace"
xmlns:tar1="namespace">
<soapenv:Header/>
<soapenv:Body>
<tar:RegisterUser>
<tar1:Source>?</tar1:Source>
<tar1:Profile>
<tar1:EmailAddress>?</tar1:EmailAddress>
</tar1:Profile>
</tar:RegisterUser>
</soapenv:Body>
</soapenv:Envelope>
我希望我的输出是这样的:
And I want my output to be something like this:
<tar:RegisterUser xmlns:tar="namespace" xmlns:tar1="namespace">
<tar1:Source>?</tar1:Source>
<tar1:Profile>
<tar1:EmailAddress>?</tar1:EmailAddress>
</tar1:Profile>
</tar:RegisterUser>
有人可以向我提供一些有关如何执行此操作的想法吗?
Can someone provide me with some ideas on how to do this?
推荐答案
这摆脱了 soapenv:
元素和命名空间声明.
This gets rid of the soapenv:
elements and the namespace declaration.
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
>
<xsl:output indent="yes" />
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="soapenv:*">
<xsl:apply-templates select="@* | node()" />
</xsl:template>
</xsl:stylesheet>
结果:
<tar:RegisterUser xmlns:tar="namespace">
<tar1:Source xmlns:tar1="namespace">?</tar1:Source>
<tar1:Profile xmlns:tar1="namespace">
<tar1:EmailAddress>?</tar1:EmailAddress>
</tar1:Profile>
</tar:RegisterUser>
这篇关于XSLT 删除 SOAP 信封但保留名称空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文