XSLT 1.0, need to globally replace apostrophes in XML output with &apos; entity
===

I'm transforming XML and have to map some descriptive, plain English metadata to an attribute value, like so:

    <Element Value="He's going to have to"></Element>

As a part of the initial transformation process, double quotes are used for all attribute values, and if there's double quotes in the submitted metadata, they are already converted like so:

    <Element Value="makes for &quot;great TV,&quot; he manipulates"></Element>

So I don't need to worry about escaping those characters. I shouldn't have to worry about apostrophes within double quotes, but I'm being asked to ensure that all the apostrophes are converted to their entity like so:

    <Element Value="He&apos;s going to have to"></Element>

But I may not be able to accomplish this on initial transformation, like with the quotation marks, because I don't have access to that system - I'll need to do this after the XML has been ingested with another XSL transformation downstream.

What's the simplest way to accomplish a search & replace via XSLT 1.0 to do this? Obviously I could just hand edit the final XML, but I'm looking for an automated, scripted process. I've seen the replace-string template posted on these boards, but I'm obviously not crafting the structure correctly, because it's not doing anything to my XML when I apply it..

    	<xsl:template name="replace-string">
		<xsl:param name="text"/>
		<xsl:param name="replace"/>
		<xsl:param name="with"/>
		<xsl:choose>
			<xsl:when test="contains($text,$replace)">
				<xsl:value-of select="substring-before($text,$replace)"/>
				<xsl:value-of select="$with"/>
				<xsl:call-template name="replace-string">
					<xsl:with-param name="text" select="substring-after($text,$replace)"/>
					<xsl:with-param name="replace" select="$replace"/>
					<xsl:with-param name="with" select="$with"/>
				</xsl:call-template>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="$text"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	<xsl:template match="/">
		<xsl:variable name="apos1">'</xsl:variable>
		<xsl:variable name="apos2">&apos;</xsl:variable>
		<xsl:call-template name="replace-string">
			<xsl:with-param name="text" select="."/>
			<xsl:with-param name="replace" select=" $apos1 "/>
			<xsl:with-param name="with" select=" $apos2 "/>
		</xsl:call-template>
	</xsl:template>