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
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>
Result:
<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>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<xsl:copy-of select="/soapenv:Envelope/soapenv:Body/*"/>
</xsl:template>
</xsl:stylesheet>
Output:
<?xml version="1.0" encoding="utf-8"?>
<tar:RegisterUser xmlns:tar="namespace" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tar1="namespace">
<tar1:Source>?</tar1:Source>
<tar1:Profile>
<tar1:EmailAddress>?</tar1:EmailAddress>
</tar1:Profile>
</tar:RegisterUser>
Unfortunately, I could not find any easy way to remove the xmlns:soapenv
attribute.