cancel
Showing results for 
Search instead for 
Did you mean: 

xslt code to replace a node name to include ns0 prefix

Former Member
0 Kudos

Hi,

Is there some easy xslt code to change the following: (I want the ns0 tag and namespace introduced in the root node so that my mapping works. I have created the mapping using externally provided wsdl, but the input message expects the prefix ns0 whereas the message coming to me from third party does not have the prefix. So in order to force it through the mapping I am thinking of using xslt to translate <createOrUpdateJobsResponse> to <ns0:createOrUpdateJobsResponse xmlns:ns0="http://service.webservice.xxxxxxxx.com"> and the closing tag </createOrUpdateJobsResponse> to </ns0:createOrUpdateJobsResponse>.

Source:

<?xml version="1.0" encoding="UTF-8"?>

<createOrUpdateJobsResponse>

<createOrUpdateJobsReturn>

<errorCode/>

<errorMessage/>

<goodResult/>

<jobReferenceNumber/>

</createOrUpdateJobsReturn>

</createOrUpdateJobsResponse>

Target:

<?xml version="1.0" encoding="UTF-8"?>

<ns0:createOrUpdateJobsResponse xmlns:ns0="http://service.webservice.xxxxxxxx.com">

<createOrUpdateJobsReturn>

<errorCode/>

<errorMessage/>

<goodResult/>

<jobReferenceNumber/>

</createOrUpdateJobsReturn>

</ns0:createOrUpdateJobsResponse>

Accepted Solutions (0)

Answers (3)

Answers (3)

former_member190389
Active Contributor
0 Kudos
Former Member
0 Kudos

Hi James,

You could give a try with this :

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns0="http://service.webservice.xxxxxxxx.com" version="1.0">

<xsl:output indent="yes" omit-xml-declaration="no"/>

<xsl:template match="/">

<ns0:createOrUpdateJobsResponse>

<xsl:apply-templates/>

</ns0:createOrUpdateJobsResponse>

</xsl:template>

<xsl:template match="createOrUpdateJobsReturn">

<xsl:copy-of select="."/>

</xsl:template>

</xsl:stylesheet>

It should recreate the same msg structure with a ns0 namespace for the output document

Rgds

Chris

Former Member
0 Kudos

Hey

You can have a look at the discussion in the following blog

Thanx

Aamir