I am trying to set a namespace on a soapenv:Header element that changes based on a param passed into xslt.
Here is my template I am using and the expected output is below.
The input to the xslt are the 3 params which contain a namespace, that varies, request method and the body of the message, which is just copied.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="2.0">
<xsl:param name="RequestNameSpace" />
<xsl:param name="RequestMethod"/>
<xsl:param name="RequestMessageBody" />
<xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>
<xsl:template match="/" >
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:myns="{$RequestNameSpace}">
<soapenv:Header/>
<soapenv:Body>
<xsl:element name="myns:{$RequestMethod}">
<xsl:copy-of select="$RequestMessageBody" />
</xsl:element>
</soapenv:Body>
</soapenv:Envelope>
</xsl:template>
</xsl:stylesheet>
Current output, note in the soapenv:Envelope tag the namespace was not applied, what Im after is for the RequestNameSpace to be applied as it was passed in.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:myns="{$RequestNameSpace}">
<soapenv:Header/>
<soapenv:Body>
<myns:hello_world>
<test_tag>Test output</test_tag>
</myns:hello_world>
</soapenv:Body>
</soapenv:Envelope>
If anyone can point out what im doing wrong, would be great. I belive it has something to do with that fact im not using a xsl: type element for the soapenv:Envelop element, but im not sure how I go about declaring it and having the namespaces included.
Cheers