title: XSLT: Conditionally add Modify Substring
body: <p>I have a function that adds a zero-width characters.  It's not quite working the way I want it to though.  How do I get it to add the zero-space character every 15 chars <strong>only</strong> if it does not contain a normal space?</p>
  
  <pre><code>&lt;xsl:template match="text()[parent::d:entry]"&gt;
      &lt;xsl:call-template name="intersperse-with-zero-spaces"&gt;
          &lt;xsl:with-param name="str" select="."/&gt;
          &lt;xsl:with-param name="max_length" select="number(15)"/&gt;
      &lt;/xsl:call-template&gt;
  &lt;/xsl:template&gt;
  &lt;xsl:template name="intersperse-with-zero-spaces"&gt;
          &lt;xsl:param name="str"/&gt;
          &lt;xsl:param name="max_length"/&gt;
          &lt;xsl:variable name="ret"&gt;
              &lt;xsl:value-of select="substring($str, 1, $max_length)"/&gt;
              &lt;xsl:if test="string-length($str) &amp;gt; $max_length"&gt;
                  &lt;xsl:value-of select="'&amp;#x200b;'"/&gt;
                  &lt;xsl:call-template name="intersperse-with-zero-spaces"&gt;
                      &lt;xsl:with-param name="str" select="substring($str, $max_length + 1)"/&gt;
                      &lt;xsl:with-param name="max_length" select="$max_length"/&gt;
                  &lt;/xsl:call-template&gt;
              &lt;/xsl:if&gt;
          &lt;/xsl:variable&gt;
          &lt;xsl:value-of select="$ret"/&gt;
      &lt;/xsl:template&gt;
  </code></pre>