xslt 1.0 - XSLT1.0 find and relace -


i'm having problems replacing string within string using xsl 1.0. i've read various threads on site , others can't put finger on why method not work. purposes of question i've dumbed down data little you'll list, hopefully.

here xml file

<statementreportonlactivitybygame>     <gamename>testmatch5</gamename>     <statementreportonlactivitybygamedetail>         <detaildesc>1asales testmatch5</detaildesc>         <grossamount>18.000</grossamount>     </statementreportonlactivitybygamedetail>     <statementreportonlactivitybygamedetail>         <detaildesc>3avalids testmatch5</detaildesc>         <grossamount>10.000</grossamount>     </statementreportonlactivitybygamedetail>     <statementreportonlactivitybygamedetail>         <detaildesc>4acommissions testmatch5</detaildesc>         <grossamount>0.000</grossamount>     </statementreportonlactivitybygamedetail> </statementreportonlactivitybygame> 

requirement : in output need replace testmatch5 testmatch f5

xsl file

<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>       

calling template

<xsl:cal-template name="string-replace-all">     <xsl:with-param name="text" select="lsp:detaildesc" />     <xsl:with-param name="replace" select="testmatch5" />     <xsl:with-param name="by" select="'testmatch f5'" /> </xsl:cal-template> 


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -