I would like to remove the attribute Id and the namespace in the tag soap:Body by using XSLT.
My sample soap response to transform is:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
<soap:Header/>
<soap:Body wsu:Id="Body-a3aedbad-1ef4-44a9-9982-bfa5cf9fe25f" xmlns:wsu="http://docs.oasis-
open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<soap:Fault>
</soap:Fault>
</soap:Body>
</soap:Envelope>
My already implemented xslt is:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
exclude-result-prefixes="wsu">
<xsl:output method="xml" omit-xml-declaration="yes"
indent="yes" />
<!-- remove attribute Id with prefix wsu -->
<xsl:template match="@wsu:Id" />
<!-- removed unused namespace declarations in soap:Body, especially xlmns:wsu -->
<xsl:template match="*[local-name()='Body']">
<xsl:element name="{name()}">
<xsl:apply-templates select="@* | node()" />
</xsl:element>
</xsl:template>
<!-- copy all other elements -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()" />
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
The output: is
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
<soap:Header/>
<soap:Body>
<soap:Fault xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
</soap:Fault>
</soap:Body>
</soap:Envelope>
The ouput should be
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
<soap:Header/>
<soap:Body>
<soap:Fault>
</soap:Fault>
</soap:Body>
</soap:Envelope>
The attribute and the namespace is removed. The problem is that the namespace declaration is inherited to the child objects. Can anyone tell me a solution for my problem?