[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] passing the an apostrophe as a string to a param.
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 HTML: <a href="javascript:ShowClip('/clip.rm', 'Hijacking ends safely', 38804);">...</a> 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:choose> <xsl:when test="contains($content, $char)" ><xsl:value-of select="$before" />\<xsl:value-of select="$char" /><xsl:call-template name="SlashChars"> <xsl:with-param name="content" select="$after" /> <xsl:with-param name="char" select="$char" /> </xsl:call-template></xsl:when> <xsl:otherwise><xsl:value-of select="$content" /></xsl:otherwise> </xsl:choose> </xsl:template> > 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="'\'" /> </xsl:call-template> 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 " --> </xsl:call-template> > 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|