Doing the global replace is easy, provided the strings are not split across multiple text nodes. Just write an identity transformation that uses the identity template for elements:
Code:
<xsl:template match="*" mode="replace">
<xsl:copy><xsl:apply-templates select="@*|node()" mode="replace"/></xsl:copy>
</xsl:template>
and then does the replacement for attributes and text node:
Code:
<xsl:template match="text()" mode="replace">
<xsl:param name="from" as="xs:string" tunnel="yes"/>
<xsl:param name="to" as="xs:string" tunnel="yes"/>
<xsl:value-of select="replace(., $from, $to)"/>
</xsl:template>
<xsl:template match="@*" mode="replace">
<xsl:param name="from" as="xs:string" tunnel="yes"/>
<xsl:param name="to" as="xs:string" tunnel="yes"/>
<xsl:attribute name="{name()}" select="replace(., $from, $to)"/>
</xsl:template>
Then fire the thing off like this:
Code:
<xsl:apply-templates select="$input" mode="replace">
<xsl:with-param name="from" as="xs:string" tunnel="yes" select="'Hello'"/>
<xsl:with-param name="to" as="xs:string" tunnel="yes" select="'Hi'"/>
</xsl:apply-templates>
All that remains is working out how to set the initial parameters - you haven't given enough detail to help with that.