[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: search and replace along with apply-templates

Subject: Re: search and replace along with apply-templates
From: "Christopher R. Maden" <crism@xxxxxxxxxx>
Date: Sun, 19 Nov 2000 17:39:21 -0800
xsl replace single quote
At 07:55 19-11-2000 -0800, Robert Koberg wrote:
I have some JavaScript functions that, on click of a glossed word, open a
new window and writes to it with document.write.  That all works fine except
there is potential for it to break if the defintion contains a single quote.
Is there some way to apply-templates and search for the single quote
character and prepend the js escape character "\" to the single quote?

<xsl:template name="fixQuotes"> <xsl:param name="do.quote"/> <xsl:param name="string"/> <xsl:choose> <xsl:when test="$do.quote"> <xsl:choose> <xsl:when test="contains($string, &quot;'&quot;)"> <xsl:value-of select="substring-before($string, &quot;'&quot;)"/> <xsl:text>\'</xsl:text> <xsl:call-template name="fixQuotes"> <xsl:with-param name="do.quote" select="$do.quote"/> <xsl:with-param name="string" select="substring-after($string, &quot;'&quot;)"/> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:value-of select="$string"/> </xsl:otherwise> </xsl:choose> </xsl:when> <xsl:otherwise> <xsl:value-of select="$string"/> </xsl:otherwise> </xsl:choose> </xsl:template>

HTH,
Chris
--
Christopher R. Maden, Senior XML Analyst, Lexica LLC
222 Kearny St., Ste. 202, San Francisco, CA 94108-4510
+1.415.901.3631 tel./+1.415.477.3619 fax
<URL:http://www.lexica.net/> <URL:http://www.oreilly.com/%7Ecrism/>


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



Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.