title: Dynamically update text nodes in XSLT
body: <p>I'm trying to update the text nodes in xml based on the check if it matches a certain pattern</p>
  
  <p>in xslt 1.0</p>
  
  <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:regexp="http://exslt.org/regular-expressions"&gt;
      &lt;xsl:output method="xml" version="1.0"/&gt;
      &lt;xsl:template match="@*|node()"&gt;
          &lt;xsl:copy&gt;
              &lt;xsl:apply-templates select="@*|node()"/&gt;
          &lt;/xsl:copy&gt;
      &lt;/xsl:template&gt;
      &lt;xsl:template match="text()"&gt;
          &lt;xsl:copy&gt;
              &lt;xsl:call-template name="CheckAndReplace"&gt;
                  &lt;xsl:with-param name="text" select="."/&gt;
                  &lt;xsl:with-param name="pattern" select="&amp;#129;"/&gt;
              &lt;/xsl:call-template&gt;
          &lt;/xsl:copy&gt;
      &lt;/xsl:template&gt;
      &lt;xsl:template name="CheckAndReplace"&gt;
          &lt;xsl:param name="text"/&gt;
          &lt;xsl:param name="pattern"/&gt;
          &lt;xsl:for-each select="regexp:match( $text, $pattern, 'gi' )"&gt;
              &lt;xsl:copy-of select="regexp:replace( $text, $pattern, 'gi','*' )"
          &lt;/xsl:for-each&gt;
      &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>XML:</p>
  
  <pre><code>&lt;Root&gt;
   &lt;Name&gt; Kabir &lt;/Name&gt;
   &lt;Id&gt; &amp;#129; &lt;/Id&gt;
  &lt;/Root&gt;
  </code></pre>
  
  <p>Here the request has ID tag which matches my pattern and that needs to be replaced </p>
  
  <p>Result Required:</p>
  
  <pre><code>&lt;Root&gt;
   &lt;Name&gt; Kabir &lt;/Name&gt;
   &lt;Id&gt; * &lt;/Id&gt;
  &lt;/Root&gt;
  </code></pre>