I am receiving a soap message(XML) and after adding a new XML element i have to send it further to another service. Is it possible to add the element by using XSLT 2.0. If so then how?
Input Message
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<tns:GLBookingMessage xmlns:tns="http://com.example/cdm/finance/generalledger/v1">
<tns:GLBooking>
</tns:GLBooking>
</tns:GLBookingMessage>
</soapenv:Body>
</soapenv:Envelope>
Required Output Message:
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<tns:GLBookingMessage xmlns:tns="http://com.example/cdm/finance/generalledger/v1">
<CHeader>
</CHeader>
<tns:GLBooking>
</tns:GLBooking>
</tns:GLBookingMessage>
</soapenv:Body>
</soapenv:Envelope>
XSLT Sheet:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:cdm="http://com.example//cdm/finance/generalledger/v1"
xmlns:tns="http://com.example//cdm/finance/generalledger/v1"
xmlns:cur="http://com.example//cdm/currencycodes/v1"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
>
<xsl:output method="xml" encoding="utf-8" indent="yes"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="//GLBookingMessage">
<GLBookingMessage>
<xsl:copy-of select="."/>
<CHeader>
</CHeader>
</GLBookingMessage>
</xsl:template>
</xsl:stylesheet>