<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">Description: use EXSLT "replace" function when available
 A recursive implementation  of string.subst is problematic,
 long strings with many matches will cause stack overflows.
Author: Peter De Wachter &lt;pdewacht@gmail.com&gt;
Bug-Debian: https://bugs.debian.org/750593

--- a/lib/lib.xsl
+++ b/lib/lib.xsl
@@ -10,7 +10,10 @@
      This module implements DTD-independent functions
 
      ******************************************************************** --&gt;
-&lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"&gt;
+&lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                xmlns:str="http://exslt.org/strings"
+                exclude-result-prefixes="str"
+                version="1.0"&gt;
 
 &lt;xsl:template name="dot.count"&gt;
   &lt;!-- Returns the number of "." characters in a string --&gt;
@@ -56,6 +59,9 @@
   &lt;xsl:param name="replacement"/&gt;
 
   &lt;xsl:choose&gt;
+    &lt;xsl:when test="function-available('str:replace')"&gt;
+      &lt;xsl:value-of select="str:replace($string, string($target), string($replacement))"/&gt;
+    &lt;/xsl:when&gt;
     &lt;xsl:when test="contains($string, $target)"&gt;
       &lt;xsl:variable name="rest"&gt;
         &lt;xsl:call-template name="string.subst"&gt;
</pre></body></html>