XSLT не очень хорош в рекурсии и манипуляции со строками, и для этого требуется и то и другое, но это возможно. Вот мое решение (которое может иметь больше условий, чем необходимо, если вы можете быть уверены в определенных шаблонах строки (например, если «WasToken» всегда находится в начале строки)):
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" />
<xsl:variable name="long.string">WasToken=AAECAzREQjgyNTY3NERCODI2Q0Zjbj1zYmswMi9vdT1iaG5zbS9vdT1pc2hzZy9vdT1kaXZhZG1pbi9vPWRvaANcWzW6mcn5IzHXtLr+BuYEMPTX; sessiontoken=DstTDbgX0ydK/nAixEvkBQCHrZ5CAar2DGq55U0Mo/6ll1+XEad3/cWyeXdO6hwmBePreLIW5d4CaoxiZHMEwuI5faG1j0UeRNizNJAw8JqEI0HuhpdpY5qSO46Iz+8WffmQoyemD/eQnWMkCeJbMwMHGIebSh7Q9mfC7wqoMqr+28IoeOYM93pPqVVwTiGOXEmiWdcp1S6WTKyw17E06S0GDlLA8eZlFFxFksgGtQiqsmp2vevWvz2dpmYYUPZ6TK3+vsNjkV2urGj24DHIrFGgU5J2eJq9qNEdEAtsuH71TJ6R0pyVK6h4FpaT1p5KurkdAZlIOl/Rpuzw2rnDNVJgW4PzWkeKIjoDDhlUhZ2cM4nNBoHqMGCz2HkwwbU72QVTzzXgwhOXtjrUlaaoZA==; WasToken=AAECAzREQjgyNTY3NERCODI2Q0Zjbj1zYmswMi9vdT1iaG5zbS9vdT1pc2hzZy9vdT1kaXZhZG1pbi9vPWRvaANcWzW6mcn5IzHXtLr+BuYEMPTX; NonceToken=61AF4E4A72A6749A8525787E0071880F; spikerAcceptLanguages=en-us%2Cen%3Bq%3D0.5; spikerStringLocale=en; spikerStyleLocale=en</xsl:variable>
<xsl:template match="/">
<!-- This template can be called from different places with different params fed into it for the beginning and ending delimiters and the string to be inserted. -->
<xsl:call-template name="convert.string">
<xsl:with-param name="string" select="$long.string" />
<xsl:with-param name="delim.beg">WasToken=</xsl:with-param>
<xsl:with-param name="delim.end">; </xsl:with-param>
<xsl:with-param name="ins.string">path=/; domain=.myorg.com ; </xsl:with-param>
</xsl:call-template>
</xsl:template>
<!-- This is a template that will potentially be called later from itself (recursed) -->
<xsl:template name="convert.string">
<xsl:param name="string" />
<xsl:param name="delim.beg" />
<xsl:param name="delim.end" />
<xsl:param name="ins.string" />
<xsl:choose>
<!-- Do a test using "starts-with" first (instead of just "contains") in case there's a situation where the ending delimiter text precedes the beginning delimiter text. -->
<xsl:when test="starts-with($string, $delim.beg) and contains($string, $delim.end)">
<!-- Output everything up until the first instance of the ending delimiter. -->
<xsl:value-of select="substring($string, 1, string-length(substring-before($string,$delim.end)))" />
<!-- Output the ending delimiter. -->
<xsl:value-of select="$delim.end" />
<!-- Ouput the string to be inserted. -->
<xsl:value-of select="$ins.string" />
<!-- Call this template again but only using the remainder text that follows the ending delimiter. -->
<xsl:call-template name="convert.string">
<xsl:with-param name="string" select="substring-after($string, $delim.end)" />
<xsl:with-param name="delim.beg" select="$delim.beg" />
<xsl:with-param name="delim.end" select="$delim.end" />
<xsl:with-param name="ins.string" select="$ins.string" />
</xsl:call-template>
</xsl:when>
<!-- This test catches text that contains (but doesn't start with) a set of delimiters (perhaps after $string was truncated in a previous pass). It outputs everything in the string up until the first instance of the beginning delimiter. -->
<xsl:when test="contains($string, $delim.beg) and contains(substring-after($string, $delim.beg), $delim.end)">
<xsl:value-of select="substring-before($string, $delim.beg)" />
<xsl:call-template name="convert.string">
<xsl:with-param name="string" select="substring-after($string, $delim.end)" />
<xsl:with-param name="delim.beg" select="$delim.beg" />
<xsl:with-param name="delim.end" select="$delim.end" />
<xsl:with-param name="ins.string" select="$ins.string" />
</xsl:call-template>
</xsl:when>
<!-- Output the remainder text (or all of the text if the delimiters were never found). -->
<xsl:otherwise>
<xsl:value-of select="$string" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>