I am very new to XSL and i need some help with my XSL ,I have request where i need to replace the string defined with in the namespace SPR to a different string but for somereason my XSL doesnt work,could some one help me out where it went wrong.
XML:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://xyz.com/xsd">
<soapenv:Header>
<xsd:myHeader>
<!--Optional:-->
<APP_ID>APP_ID</APP_ID>
</xsd:myHeader>
</soapenv:Header>
<soapenv:Body>
<tns:SPR xmlns:tns="http://xyz.com/xsd">
<Info>
<System>
<id>id</id>
<sourceSystemName>sourceSystemName</sourceSystemName>
</System>
<Type>transmissionType</Type>
<Id>encounterId</Id>
</Info>
</tns:SPR>
</soapenv:Body>
</soapenv:Envelope>
XSL:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:for-each select="/Header/Body/SubmitPreClaimRequest/*[namespace-uri(.)='']">
<xsl:call-template name="string-replace-all">
<xsl:with-param name="text" select="/Header/Body/SPR" />
<xsl:with-param name="replace" select="SPR" />
<xsl:with-param name="by" select="ONE" />
</xsl:call-template>
</xsl:for-each>
<xsl:apply-templates />
</xsl:template>
<xsl:template name="string-replace-all">
<xsl:param name="text" />
<xsl:param name="replace" />
<xsl:param name="by" />
<xsl:choose>
<xsl:when test="contains($text,$replace)">
<xsl:value-of select="substring-before($text,$replace)" />
<xsl:value-of select="$by" />
<xsl:call-template name="string-replace-all">
<xsl:with-param name="text" select="substring-after($text,$replace)" />
<xsl:with-param name="replace" select="$replace" />
<xsl:with-param name="by" select="$by" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$text" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
Result with my XSL:
<?xml version="1.0" encoding="UTF-16"?>APP_IDidsourceSystemNametransmissionTypeencounterId
EXPECTED Result:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://xyz.com/xsd">
<soapenv:Header>
<xsd:myHeader>
<!--Optional:-->
<APP_ID>APP_ID</APP_ID>
</xsd:myHeader>
</soapenv:Header>
<soapenv:Body>
**<tns:ONE xmlns:tns="http://xyz.com/xsd">**
<Info>
<System>
<id>id</id>
<sourceSystemName>sourceSystemName</sourceSystemName>
</System>
<Type>transmissionType</Type>
<Id>encounterId</Id>
</Info>
**</tns:ONE>**
</soapenv:Body>
</soapenv:Envelop