I have some xml as follows...
<ns1:service1 xmlns:ns1="http://foo.com/service_1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ns1:SystemInfo>
<ns1:functionMode>Y</ns1:functionMode>
</ns1:SystemInfo>
</ns1:service>
Now I need to take it and do 2 things
Wrap in a SOAP envelope
insert a trans tag in SystemInfo
the following works for wrapping...
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:param name = "transId" />
<xsl:template match="#*|node()">
<xsl:copy>
<xsl:apply-templates select="#*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="*">
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<xsl:copy-of select="/*"/>
</soapenv:Body>
</soapenv:Envelope>
</xsl:template>
</xsl:stylesheet>
Now I need to add the tag, problem is we do not know what the Namespace is (and it could change per request). So I can't hardcode it. However, it will already be in the root tag.
So after I would want...
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<ns1:service1 xmlns:ns1="http://foo.com/service_1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ns1:SystemInfo>
<ns1:trans />
<ns1:functionMode>Y</ns1:functionMode>
</ns1:SystemInfo>
</ns1:service>
</soapenv:Body>
</soapenv:Envelope>
But this doesn't seem to accomplish it....
<xsl:template match="*[local-name()='SystemInfo']">
<xsl:copy>
<xsl:element name="type"/>
<xsl:call-template name="copy-children"/>
</xsl:copy>
</xsl:template>
<!-- Copy the children of the current node. -->
<xsl:template name="copy-children">
<xsl:copy-of select="./*"/>
</xsl:template>
What should the above be instead?
Instead if using xsl:copy-of which will just copy the current element without allowing you to make any changes, use xsl:apply-templates
<soapenv:Body>
<xsl:apply-templates select="#*|node()"/>
</soapenv:Body>
Then you can write a template to match your SystemInfo element, and add whatever new elements you need. You could even make use of the namespace-uri function to add it with the same namespace.
<xsl:template match="*[local-name()='SystemInfo']">
<xsl:copy>
<xsl:element name="trans" namespace="{namespace-uri()}" />
<xsl:apply-templates select="#*|node()"/>
</xsl:copy>
</xsl:template>
Try this XSLT
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:param name="transId"/>
<xsl:template match="#*|node()">
<xsl:copy>
<xsl:apply-templates select="#*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="/">
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<xsl:apply-templates select="#*|node()"/>
</soapenv:Body>
</soapenv:Envelope>
</xsl:template>
<xsl:template match="*[local-name()='SystemInfo']">
<xsl:copy>
<xsl:element name="trans" namespace="{namespace-uri()}" />
<xsl:apply-templates select="#*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Related
I'm developing an application and I need to add several elements into the header of soap message I receive. The problem is I don't know which prefix the namespace I'm using for adding these elements is using, but it's sure there will be several elements in the body using this prefix, so the namespace is already declared in the message.
For example, I'm receiving this message:
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:enterprise.soap.sforce.com" xmlns:urn1="urn:sobject.enterprise.soap.sforce.com">
<soapenv:Header/>
<soapenv:Body>
<urn:operation>
</urn:operation>
</soapenv:Body>
</soapenv:Envelope>
And the xpath expression I use for adding these elements in the header is:
<xsl:stylesheet version="1.0" exclude-result-prefixes="xsi xsl" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<xsl:output method="xml" encoding="UTF-8" indent="yes" omit-xml-declaration="yes"/>
<xsl:param name="Getsed">aBcDeFgHiJkLmNñOpQrStUvWxYz</xsl:param>
<xsl:template match="#* | node()">
<xsl:copy>
<xsl:apply-templates select="#* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="//*[local-name()='Header']">
<xsl:copy>
<urn:SH xmlns:urn="urn:enterprise.soap.sforce.com">
<urn:sed><xsl:value-of select="$Getsed"/></urn:sed>
</urn:SH>
<xsl:apply-templates select="node()|#*"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
I would like to use the prefix (urn) already declared for the namespace urn:enterprise.soap.sforce.com.
Could you please give me a hand?
I believe a silly workaround like <xsl:value-of select="substring-before(name(//*[namespace-uri() = 'urn:enterprise.soap.sforce.com']), ':')" /> will fit your needs.
Thus your template can be rewrited that way:
<xsl:template match="*[local-name()='Header']">
<!-- this will retrieve the namespace prefix in source document -->
<xsl:variable name="ns-sforce">
<xsl:value-of select="substring-before(name(//*[namespace-uri() = 'urn:enterprise.soap.sforce.com']), ':')" />
</xsl:variable>
<xsl:copy>
<!-- create prefixed elements with the same value as before -->
<xsl:element name="{$ns-sforce}:SH" namespace="urn:enterprise.soap.sforce.com">
<xsl:element name="{$ns-sforce}:sed" namespace="urn:enterprise.soap.sforce.com">
<xsl:value-of select="$Getsed"/>
</xsl:element>
</xsl:element>
<xsl:apply-templates select="node()|#*"/>
</xsl:copy>
</xsl:template>
Note: <xsl:template match="//*[local-name()='Header']"> can be replaced by <xsl:template match="*[local-name()='Header']">
I have the requirement to add the prefix to the namespace.
Input XML:
<soapenv:Body xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<ProductMovementReport Version="5.0" xmlns="urn:cidx:names:specification:ces:schema:all:5:0">
<Header>
<ThisDocumentIdentifier>
<DocumentIdentifier>868</DocumentIdentifier>
</ThisDocumentIdentifier>
</Header>
</ProductMovementReport>
</soapenv:Body>
I also need to change the value of the Version ="'5'" which I am able to get successfully.
Below the is the desire output.
<soapenv:Body xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<urn1:ProductMovementReport Version="4.0" xmlns:urn1="urn:cidx:names:specification:ces:schema:all:4:0">
<urn1:Header>
<urn1:ThisDocumentIdentifier>
<urn1:DocumentIdentifier>868</urn1:DocumentIdentifier>
</urn1:ThisDocumentIdentifier>
</urn1:Header>
</urn1:ProductMovementReport>
</soapenv:Body>
I have written the code for this and everything is working except the namespace part is not getting change. I guess I am missing something in the template match.
Code:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="node()|#*">
<xsl:copy>
<xsl:apply-templates select="node()|#*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="#*">
<xsl:choose>
<xsl:when test="local-name() = 'Version' ">
<xsl:attribute name="{local-name()}"><xsl:value-of select="'4.0'"/></xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="{local-name()}"><xsl:value-of select="."/></xsl:attribute>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="*">
<xsl:element name="urn1:{local-name()}" namespace="urn:cidx:names:specification:ces:schema:all:4:0">
<xsl:copy-of select="namespace::*"/>
<xsl:apply-templates select="#*|node()"/>
</xsl:element>
</xsl:template>
Here is the link in case I missed anything http://xsltransform.net/bdxtpP.
I am very close to solving it except namespace part.
Can anyone please point me where I am doing it wrong?
Your match for match="*" is matching all elements regardless of namespace. Try narrowing the scope by testing the namespace URI.
XSLT 1.0
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="#*|node()">
<xsl:copy>
<xsl:apply-templates select="#*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="*[namespace-uri()='urn:cidx:names:specification:ces:schema:all:5:0']">
<xsl:element name="urn1:{local-name()}" namespace="urn:cidx:names:specification:ces:schema:all:4:0">
<xsl:apply-templates select="#*|node()"/>
</xsl:element>
</xsl:template>
<xsl:template match="#Version">
<xsl:attribute name="{name()}">
<xsl:text>4.0</xsl:text>
</xsl:attribute>
</xsl:template>
</xsl:stylesheet>
Output
<soapenv:Body xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<urn1:ProductMovementReport xmlns:urn1="urn:cidx:names:specification:ces:schema:all:4:0" Version="4.0">
<urn1:Header>
<urn1:ThisDocumentIdentifier>
<urn1:DocumentIdentifier>868</urn1:DocumentIdentifier>
</urn1:ThisDocumentIdentifier>
</urn1:Header>
</urn1:ProductMovementReport>
</soapenv:Body>
I'd like to copy only header element with all subnodes and add to every subnode prefix "v11"(including header element)
Source xml:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns3:createReservationRequest xmlns:ns3="ns3URL" xmlns:ns2="ns2URL">
<header>
<language isoCountryCode="US" isoLanguageCode="en"/>
<channel name="DT">
<subChannel name="WEBWB">
<subChannel name="WEBWB">
<subChannel name="Functester">
<subChannel name="ecom"/>
</subChannel>
</subChannel>
</subChannel>
</channel>
</header>
<ns3:agentInfo>
<ns2:agentDutyCode>PR</ns2:agentDutyCode>
</ns3:agentInfo>
</ns3:createReservationRequest>
</soap:Body>
</soap:Envelope>
Desired result xml:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:v1="v1URL"
xmlns:v11="v11URL">
<soapenv:Body>
<v1:createBookerEventRequest>
<v11:header>
<v11:channel name="DT">
<v11:subChannel name="WEBWB">
<v11:subChannel name="WEBWB">
<v11:subChannel name="Functester">
<v11:subChannel name="ecom"/>
</v11:subChannel>
</v11:subChannel>
</v11:subChannel>
</v11:channel>
</v11:header>
</v1:createBookerEventRequest>
</soapenv:Body>
</soapenv:Envelope>
I've tried to implement this using example from here . I've written the following xsl:
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:v11="v11URL">
<xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>
<xsl:template match="/">
<xsl:copy>
<xsl:apply-templates select="//*[local-name()='header']/*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="//*[local-name()='header']/*">
<xsl:element name="v11:{name()}" inherit-namespaces="no">
<xsl:apply-templates select="node()|#*"/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
But it doesn't copy subchannels into result xml. And also adds unwanted "xmlns:v11="http://example.com/schema/common/ATPCommonServiceTypes/v1" attribute to header subnodes. Any help is appreciated
Here is my (edited) suggestion:
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:v1="v1URL"
xmlns:v11="v11URL"
xmlns:ns3="ns3URL"
exclude-result-prefixes="soap ns3">
<xsl:template match="#* | node()">
<xsl:copy>
<xsl:apply-templates select="#* , node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="/*">
<xsl:copy>
<xsl:copy-of select="document('')/xsl:stylesheet/namespace::*[local-name() = ('v1', 'v11')]"/>
<xsl:apply-templates select="#* , node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="*[not(namespace-uri())]">
<xsl:element name="v11:{local-name()}">
<xsl:apply-templates select="#* , node()"/>
</xsl:element>
</xsl:template>
<xsl:template match="ns3:createReservationRequest">
<v1:createBookerEventRequest>
<xsl:apply-templates select="#* , node()"/>
</v1:createBookerEventRequest>
</xsl:template>
<xsl:template match="ns3:agentInfo"/>
</xsl:stylesheet>
I added a xmlns declaration to agentDutyCode since it is missing a namespace declaration:
<ns2:agentDutyCode xmlns:ns2="ns2URL">PR</ns2:agentDutyCode>
Using the source with this stylesheet (templates explained in the comments):
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:v11="v11URL"
xmlns:v1="v1URL"
xmlns:ns3="ns3URL"
exclude-result-prefixes="ns3">
<xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>
<xsl:strip-space elements="*"/>
<!-- Copies Envelope and Body preserving their namespace -->
<xsl:template match="soap:Envelope | soap:Body">
<xsl:copy>
<xsl:apply-templates select="node()|#*"/>
</xsl:copy>
</xsl:template>
<!-- Creates the createReservationRequest element -->
<xsl:template match="ns3:createReservationRequest">
<v1:createBookerEventRequest>
<xsl:apply-templates/>
</v1:createBookerEventRequest>
</xsl:template>
<!-- Ignores language and agentInfo subtrees -->
<xsl:template match="language"/>
<xsl:template match="ns3:agentInfo"/>
<!-- Matches all other elements -->
<xsl:template match="*">
<xsl:element name="v11:{local-name()}" inherit-namespaces="no">
<xsl:apply-templates select="node()|#*"/>
</xsl:element>
</xsl:template>
<!-- Copies attributes -->
<xsl:template match="#*">
<xsl:copy>
<xsl:value-of select="."/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
You will have this result:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<v1:createBookerEventRequest xmlns:v11="v11URL" xmlns:v1="v1URL">
<v11:header>
<v11:channel name="DT">
<v11:subChannel name="WEBWB">
<v11:subChannel name="WEBWB">
<v11:subChannel name="Functester">
<v11:subChannel name="ecom"/>
</v11:subChannel>
</v11:subChannel>
</v11:subChannel>
</v11:channel>
</v11:header>
</v1:createBookerEventRequest>
</soap:Body>
</soap:Envelope>
Here is an XSLT Fiddle where you can see the result.
I have a source XML
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body>
<PublishANZINCIDENTESB xmlns="http://www.ibm.com/maximo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" creationDateTime="2013-02-25T23:25:35+00:00" transLanguage="EN" baseLanguage="EN" messageID="1361834735434709840" maximoVersion="7 1 20110105-1024 V7118-37" event="1"><ANZINCIDENTESBSet><INCIDENT action="Replace"></INCIDENT></ANZINCIDENTESBSet></PublishANZINCIDENTESB></soapenv:Body></soapenv:Envelope>
I would like to change to target XML by adding namespace and header to the tag. The output XML is
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:s600="http://LIB_ISM_WPS/S600_PublishANZINCIDENT_Service_INT" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Header/><soapenv:Body>
<s600:PublishANZINCIDENTESBOperation><PublishANZINCIDENTESB xmlns="http://www.ibm.com/maximo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" creationDateTime="2013-02-25T23:25:35+00:00" transLanguage="EN" baseLanguage="EN" messageID="1361834735434709840" maximoVersion="7 1 20110105-1024 V7118-37" event="1"><ANZINCIDENTESBSet><INCIDENT action="Replace"></INCIDENT></ANZINCIDENTESBSet></PublishANZINCIDENTESB></s600:PublishANZINCIDENTESBOperation></soapenv:Body></soapenv:Envelope>
XSL I am using:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:s600="http://LIB_ISM_WPS/S600_PublishANZINCIDENT_Service_INT" >
<s600:PublishANZINCIDENTESBOperation>
<xsl:template match="node()|#*">
<xsl:copy>
<xsl:apply-templates select="node()|#*"/>
</xsl:copy>
</xsl:template>
</s600:PublishANZINCIDENTESBOperation>
<xsl:template match="*">
<xsl:element name="s600:{name()}" namespace="http://LIB_ISM_WPS/S600_PublishANZINCIDENT_Service_INT">
<xsl:copy-of select="namespace::*"/>
<xsl:apply-templates select="node()|#*"/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
Can anyone please help me as soon as possible as it is getting my head around?
From your input and output examples it looks like you simply want to wrap an s600:PublishANZINCIDENTESBOperation element around the content of the soapenv:Body but otherwise leave the content unchanged. You can achieve this with
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:s600="http://LIB_ISM_WPS/S600_PublishANZINCIDENT_Service_INT"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<xsl:template match="#*|node()">
<xsl:copy><xsl:apply-templates select="#*|node()" /></xsl:copy>
</xsl:template>
<xsl:template match="soapenv:Body">
<xsl:copy>
<s600:PublishANZINCIDENTESBOperation>
<xsl:apply-templates select="#*|node()" />
</s600:PublishANZINCIDENTESBOperation>
</xsl:copy>
</xsl:template>
<!-- If the namespace declaration absolutely _must_ be on the Envelope
you could uncomment this extra template -->
<!--
<xsl:template match="soapenv:Envelope">
<soapenv:Envelope>
<xsl:apply-templates select="#*|node()" />
</soapenv:Envelope>
</xsl:template>
-->
</xsl:stylesheet>
This will produce the output you're looking for, except that the xmlns:s600 declaration will be on the s600:PublishANZINCIDENTESBOperation element rather than on the soapenv:Envelope, but this shouldn't matter to downstream components provided they are using a proper XML parser to process the data rather than treating it as text. Uncomment the third template if it is really important to have the declaration on the envelope instead.
below is the input xml:
<ns:TXLife xmlns:ns="http://ACORD.org/Standards/Life/2">
<TXLifeResponse>
<TransRefGUID/>
<TransExeDate/>
<TransExeTime/>
<TransType tc="228"/>
</ns:TXLife>
and below is my XSLT :
xmlns:ns="http://ACORD.org/Standards/Life/2" version="1.0">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="/">
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:acor="http://www.foresters.com/esb/ws/wsdl/ACORD-v1.0" xmlns:ns="http://ACORD.org/Standards/Life/2">
<soapenv:Header/>
<soapenv:Body>
<xsl:copy>
<xsl:apply-templates />
</xsl:copy>
</soapenv:Body>
</soapenv:Envelope>
</xsl:template>
<xsl:template match="node() [local-name(.) = 'TXLife']">
<xsl:element name="ns:{local-name()}">
<xsl:apply-templates select="#*|node()"/>
</xsl:element>
</xsl:template>
By using this tranformation i am not able to add namespace prefix to all the child element of TXLife.
how to add namespace prefix (ns) to all child elements? so that it should look as below
<ns:TXLifeResponse>
<ns:TransRefGUID/>
<ns:TransExeDate/>
<ns:TransExeTime/>
<ns:TransType tc="228"/>
</ns:TXLife>
If you want only TXLife and descendant to be under http://ACORD.org/Standards/Life/2 namespace, use this stylesheet:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ns="http://ACORD.org/Standards/Life/2"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<xsl:template match="/">
<soapenv:Envelope>
<soapenv:Header/>
<soapenv:Body>
<xsl:apply-templates/>
</soapenv:Body>
</soapenv:Envelope>
</xsl:template>
<xsl:template match="*[ancestor-or-self::ns:TXLife]">
<xsl:element name="ns:{local-name()}">
<xsl:apply-templates select="#*|node()"/>
</xsl:element>
</xsl:template>
<xsl:template match="#*|node()">
<xsl:copy>
<xsl:apply-templates select="#*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Output:
<soapenv:Envelope
xmlns:ns="http://ACORD.org/Standards/Life/2"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header />
<soapenv:Body>
<ns:TXLife>
<ns:TXLifeResponse>
<ns:TransRefGUID></ns:TransRefGUID>
<ns:TransExeDate></ns:TransExeDate>
<ns:TransExeTime></ns:TransExeTime>
<ns:TransType tc="228"></ns:TransType>
</ns:TXLifeResponse>
</ns:TXLife>
</soapenv:Body>
</soapenv:Envelope>
Your XML isn't valid, but I assume you just've missed the closing TXLifeResponse element.
The following transformation will do what you want:
XML:
<?xml version="1.0" encoding="UTF-8"?>
<ns:TXLife xmlns:ns="http://ACORD.org/Standards/Life/2">
<TXLifeResponse>
<TransRefGUID/>
<TransExeDate/>
<TransExeTime/>
<TransType tc="228"/>
</TXLifeResponse>
</ns:TXLife>
XSLT:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:ns="http://ACORD.org/Standards/Life/2">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="/">
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:acor="http://www.foresters.com/esb/ws/wsdl/ACORD-v1.0"
xmlns:ns="http://ACORD.org/Standards/Life/2">
<soapenv:Header/>
<soapenv:Body>
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</soapenv:Body>
</soapenv:Envelope>
</xsl:template>
<xsl:template match="*">
<xsl:element name="ns:{local-name()}">
<xsl:apply-templates select="#*|node()"/>
</xsl:element>
</xsl:template>
<xsl:template match="#*">
<xsl:copy-of select="."/>
</xsl:template>
</xsl:stylesheet>
Output:
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:acor="http://www.foresters.com/esb/ws/wsdl/ACORD-v1.0"
xmlns:ns="http://ACORD.org/Standards/Life/2">
<soapenv:Header/>
<soapenv:Body>
<ns:TXLife>
<ns:TXLifeResponse>
<ns:TransRefGUID/>
<ns:TransExeDate/>
<ns:TransExeTime/>
<ns:TransType tc="228"/>
</ns:TXLifeResponse>
</ns:TXLife>
</soapenv:Body>
</soapenv:Envelope>
The template xsl:template match="node()[local-name(.) = 'TXLife']" is somewhat strange to me. What are you trying to accomplish? Maybe we can help explain why this isn't the appropriate way to do it.