I need to transform the xml object into soap object.
Below is the xml object I have. I converted it from JSON object:
{
“requestXML”: {
“a1”: null,
“b1”: 2018,
“c1”: 2019,
“d1”: 1573
}
}
Converted xml file:
<?xml version="1.0" encoding="UTF-8"?>
<requestXML>
<a1/>
<b1>2018</b1>
<c1>2019</c1>
<d1>1573</d1>
</requestXML>
Now I want to convert this xml object into soap object. Below is the desired output;
<soapenv:Envelope xmlns:soapenv=http://schemas.xmlsoap.org/soap/envelope/ xmlns:sample=http://tempurl.com/>
<soapenv:Header/>
<soapenv:Body>
<sample:requestXML>
<a1></a1>
<b1>2018</b1>
<c1>2019</c1>
<d1>1573</d1>
</sample:requestXML>
</soapenv:Body>
</soapenv:Envelope>
However when i tried to do it with xslt, its giving me below object:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:sample="http://tempurl.com/">
<soapenv:Header/>
<soapenv:Body>
<sample:requestXML>
<requestXML>
<a1/>
<b1>2018</b1>
<c1>2019</c1>
<d1>1573</d1>
</requestXML>
</sample:requestXML>
</soapenv:Body>
</soapenv:Envelope>
I used below xslt for transformation:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" indent="yes" encoding="UTF-8" omit-xml-declaration="no"/>
<xsl:template match="/">
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sample="http://tempurl.com/">
<soapenv:Header/>
<soapenv:Body>
<sample:requestXML>
<xsl:copy>
<xsl:copy-of select="*"/>
<xsl:text disable-output-escaping="yes">
</xsl:text>
</xsl:copy>
</sample:requestXML>
</soapenv:Body>
</soapenv:Envelope>
</xsl:template>
</xsl:stylesheet>
@dchiesa1 : Could you please help or suggest what wrong I am putting in xslt file. I am not able to remove the root element.