This project is read-only.

ConvertEscaped

May 27, 2011 at 2:05 AM
Edited May 27, 2011 at 2:06 AM

I knew this was somewhere, but for some reason it's not here.  I found it on your demo site Marc, so I think it's best here as well. ;-)

<xsl:template name="ConvertEscaped">
	<xsl:param name="ConvertValue"/>
	<xsl:param name="LT"><xsl:text><![CDATA[&lt;]]></xsl:text></xsl:param>
	<xsl:param name="GT"><xsl:text><![CDATA[&gt;]]></xsl:text></xsl:param>
	<xsl:param name="APOS"><xsl:text><![CDATA[&#39;]]></xsl:text></xsl:param>
	
	<xsl:choose>
		<xsl:when test="contains($ConvertValue, $LT)">
			<xsl:call-template name="ConvertEscaped">
				<xsl:with-param name="ConvertValue" select="concat(substring-before($ConvertValue, $LT), '&lt;', substring-after($ConvertValue, $LT))"/>
			</xsl:call-template>	
		</xsl:when>
		<xsl:when test="contains($ConvertValue, $GT)">
			<xsl:call-template name="ConvertEscaped">
			<xsl:with-param name="ConvertValue" select="concat(substring-before($ConvertValue, $GT), '&gt;', substring-after($ConvertValue, $GT))"/>
			</xsl:call-template>	
		</xsl:when>
		<xsl:when test="contains($ConvertValue, $APOS)">
			<xsl:call-template name="ConvertEscaped">
			<xsl:with-param name="ConvertValue" select="concat(substring-before($ConvertValue, $APOS), $dvt_apos, substring-after($ConvertValue, $APOS))"/>
			</xsl:call-template>	
		</xsl:when>
		<xsl:otherwise>
			<xsl:value-of select="$ConvertValue" disable-output-escaping="yes"/>
		</xsl:otherwise>
	</xsl:choose>
</xsl:template>