Hi Amit,
I think you want a generic solution but in your case when the name of the tags and the structure change, i think is not possible to have a generic solution.
You can check if this solution is right for you:
Source XML:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v2="http://www.test.com/v2" xmlns:v21="http://www.test.com/v21" xmlns:v1="http://www.test.com/v1">
<soapenv:Header>
<v2:XHeader>
<v2:Name>name</v2:Name>
<v2:Id>id</v2:Id>
<v2:UserInformation>
<v2:Type/>
<v2:Id/>
</v2:UserInformation>
</v2:XHeader>
</soapenv:Header>
<soapenv:Body>
<v21:Info v21:version="?">
<v21:Code>code</v21:Code>
<v21:Dep>
<v21:InfoCode>infocode</v21:InfoCode>
<v21:Date>?</v21:Date>
</v21:Dep>
</v21:Info>
</soapenv:Body>
</soapenv:Envelope>
XSL:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v2="http://www.test.com/v2" xmlns:v21="http://www.test.com/v21" exclude-result-prefixes="v2 v21 soapenv">
<xsl:template match="./soapenv:Envelope">
<ns1:MaterialERPBasicDataCreateRequestMessage_sync xmlns:ns1="http://sap.com/xi/SAPGlobal/Global">
<MessageHeader>
<ID>
<xsl:value-of select="./soapenv:Header/v2:XHeader/v2:Name"/>
</ID>
<UUID>
<xsl:value-of select="./soapenv:Header/v2:XHeader/v2:Id"/>
</UUID>
</MessageHeader>
<Material>
<InternalID>Constant</InternalID>
<TypeCode>
<xsl:value-of select="./soapenv:Body/v21:Info/v21:Code"/>
</TypeCode>
<IndustrialSectorCode>
<xsl:value-of select="./soapenv:Body/v21:Info/v21:Dep/v21:InfoCode"/>
</IndustrialSectorCode>
</Material>
</ns1:MaterialERPBasicDataCreateRequestMessage_sync>
</xsl:template>
</xsl:stylesheet>
Target XML get from the XSL:
<?xml version="1.0" encoding="UTF-8"?>
<ns1:MaterialERPBasicDataCreateRequestMessage_sync xmlns:ns1="http://sap.com/xi/SAPGlobal/Global">
<MessageHeader>
<ID>name</ID>
<UUID>id</UUID>
</MessageHeader>
<Material>
<InternalID>Constant</InternalID>
<TypeCode>code</TypeCode>
<IndustrialSectorCode>infocode</IndustrialSectorCode>
</Material>
</ns1:MaterialERPBasicDataCreateRequestMessage_sync>
Hope this helps.
Regards.