Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5958489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:33:01+00:00 2026-05-22T18:33:01+00:00

I’m trying to perform a string replace through XSLT, but I actually see no

  • 0

I’m trying to perform a string replace through XSLT, but I actually see no way for that in Firefox.

When I use the XSLT 2.0 replace() function through something like this:

<xsl:value-of select="replace(., 'old', 'new')"/>

I get in Firefox the error “An unknown XPath extension function was called”.
When I try to use any XSLT 1.0 compatible template that performs the replacement I get the error “XSLT Stylesheet (possibly) contains a recursion” (of course it contains a recursion, I see no other way for performing a string replacement in XSLT without a recursive function).

So, no chance to use the XSLT 2.0 replace() function, and no chance to use a recursive template. How do I perform the trick using XSLT? Please no suggestions to make it on the server side, I implemented my whole website in order to operate client-side only transformations and I can’t roll back just because of one issue, and it’s not right that in 2011 I can’t use a powerful technology like XSLT because of its buggy and incomplete implementations.

EDIT:

The code I used is the same provided here: XSLT Replace function not found

I used this XML for testing:

<?xml version="1.0"?>
<?xml-stylesheet href="/example.xsl" type="text/xsl"?>

<content>lol</content>

and this XSLT:

<?xml version="1.0"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>

<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:template match="content">
<xsl:call-template name="string-replace-all">
<xsl:with-param name="text" select="lolasd"/>
<xsl:with-param name="replace" select="lol"/>
<xsl:with-param name="by" select="asd"/>
</xsl:call-template>
</xsl:template>
</xsl:stylesheet>

On Firefox I get “XSLT Stylesheet (possibly) contains a recursion”. Well, of course it does, otherwise it wouldn’t be a string replacement template. Other templates picked up around the net using the same style trigger the same issue as well.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T18:33:02+00:00Added an answer on May 22, 2026 at 6:33 pm

    With this document

    <content>lol</content>
    

    these parameters

    <xsl:with-param name="text" select="lolasd"/>
    <xsl:with-param name="replace" select="lol"/>
    <xsl:with-param name="by" select="asd"/>
    

    will be empty, and therefore this condition

    <xsl:when test="contains($text,$replace)">
    

    will always be true, and your code will recurse ad infinitum.

    I guess your intention was to select a string instead a node in your <xsl:with-param> elements but you forgot to use quotes/apostrophes. What you should have is something like

    <xsl:with-param name="replace" select="'lol'"/>
    

    Nevertheless, you should add a check for a case, where parameters are empty to avoid such problem, if you end up selecting emtpy strings.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I've got a string that has curly quotes in it. I'd like to replace
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to understand how to use SyndicationItem to display feed which is
I want to count how many characters a certain string has in PHP, but
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
I need a function that will clean a strings' special characters. I do NOT
I want to construct a data frame in an Rcpp function, but when I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.