Suppose the following input xml:
<div text="This is [BFboldBF]">
</div>
The goal is to transform this into this:
<div>
This is <span class="bold">bold</span> text
</div>
My xsl has the following setting:
<xsl:output method="html" encoding="utf-8" indent="no" omit-xml-declaration="yes" />
I tried substitution via the replace function
<xsl:variable name="lfL">
<xsl:text><span class="bold"></xsl:text>
</xsl:variable>
<xsl:variable name="close">
<xsl:text><span/></xsl:text>
</xsl:variable>
<xsl:variable name="text" select="@text"/>
<xsl:variable name="lfBT" select="replace($text, '\[BF', $lfL)"/>
<xsl:variable name="rfBT" select="replace($lfBT, 'BF\]', $close)"/>
and rendering the text variable via
<div>
<xsl:value-of select="$text" disable-output-escaping="yes"/>
</div>
this however does not render the xml. Instead it renders it as plain text, with the brackets escaped '<';
replacesuggests you have XSLT 2 or 3 so in any case, if your task is to analyze/process/parse plain text but to construct nodes likespanorbelements, usexsl:analyze-string(in XSLT 2 or 3) or the functionanalyze-string(in XSLT 3) instead ofreplace.