i have an input soap message, trying to replace part of namespace uri with a different string. I am able to replace entire URI with a different URI, but not able to modify the existing URI. I need to look for 'OLDSTRING' and replace with 'NEWSTRING'. The string VARIABLESTRING varies in in every input xml, so I should keep as it is in the output xml
Input XML:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:schemas-OLDSTRING-com:VARIABLESTRING">
<soapenv:Header/>
<soapenv:Body>
<requestMessage xmlns="urn:schemas-OLDSTRING-com:VARIABLESTRING">
<merchantID>TESTID</merchantID>
</requestMessage>
</soapenv:Body>
</soapenv:Envelope>
OUTPUT XML:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:schemas-NEWSTRING-com:transaction-data-1.69">
<soapenv:Header/>
<soapenv:Body>
<requestMessage xmlns="urn:schemas-NEWSTRING-com:VARIABLESTRING">
<merchantID>TESTID</merchantID>
</requestMessage>
</soapenv:Body>
</soapenv:Envelope>
I have tried the following XSL, and able to change the namespace URI, but i want to replace only 'OLDSTRING' with 'NEWSTRING' and keep remaining string as it is.
XSLT:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="@*|*|text()" />
</xsl:copy>
</xsl:template>
<xsl:template match="//*[namespace-uri()='urn:schemas-OLDSTRING-com:VARIABLESTRING']">
<xsl:element name="{local-name()}" namespace="urn:schemas-NEWSTRING-com:VARIABLESTRING" >
<xsl:apply-templates select="@*|*|text()" />
</xsl:element>
</xsl:template>
</xsl:stylesheet>