[xsl] passing the an apostrophe as a string to a param.

Subject: [xsl] passing the an apostrophe as a string to a param.
From: Adam Van Den Hoven <Adam.Hoven@xxxxxxxxxxxx>
Date: Wed, 11 Apr 2001 09:17:16 -0700
I have a named template that simply looks for all the instances of a
character in a string and adds a backslash to them so that the resulting
string, which ends up in javascript will be correctly interpreted. I needed
to convert the \ which appeared in a path into \\ so that javascript would
interpret the string correctly.

No I need to escape the apostrophes. Right now I'm generating the following
<a href="javascript:ShowClip('/clip.rm', 'Hijacking ends safely',

which is fine until I need to write out:
<a href="javascript:ShowClip('/video/2001/02/20/7464SN.rm', 'Third day's the
charm for Atlantis? 0:34', 46031);">

what I want is
<a href="javascript:ShowClip('/video/2001/02/20/7464SN.rm', 'Third day\'s
the charm for Atlantis? 0:34', 46031);">

Currently I use the following template:

<xsl:template name="SlashChars">	
	<xsl:param name="content" />
	<xsl:param name="char" />
	<xsl:variable name="before"
select="normalize-space(substring-before($content, $char))" />
	<xsl:variable name="after"
select="normalize-space(substring-after($content, $char))" />
		<xsl:when test="contains($content, $char)" ><xsl:value-of
select="$before" />\<xsl:value-of select="$char" /><xsl:call-template
				<xsl:with-param name="content"
select="$after" />
				<xsl:with-param name="char" select="$char"
		<xsl:otherwise><xsl:value-of select="$content"

> Which I call using to correct my clip URLS with:
<xsl:call-template name="SlashChars">
	<xsl:with-param name="content" select="@ClipURL" />
	<xsl:with-param name="char" select="'\'" />

but how do I do it for my captions?
<xsl:call-template name="SlashChars">
	<xsl:with-param name="content" select="@Caption" />
	<xsl:with-param name="char" select="''''" /> <!-- thats four ' in  a
row within " -->

> I am stumped.
> Or if someone has a better solution to this, I'm all ears.
> Adam van den Hoven
> Internet Application Developer
> Blue Zone
> tel. 604.685.4310
> fax. 604.685.4391
> Blue Zone makes you interactive.(tm) http://www.bluezone.net/

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread