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

Escaping apostrophes for use in javascript, etc. - how

Subject: Escaping apostrophes for use in javascript, etc. - how totrouble shoot template results?
From: "Kathy Burke" <Kathy_Burke@xxxxxxxxx>
Date: Thu, 9 Oct 2003 08:41:36 -0400
javascript apostrophe
Can't believe I forgot to include Jeni's template:

<xsl:template name="escape-apos"> 
<xsl:param name="string" />
 <!-- create an $apos variable to make it easier to refer to -->
 <xsl:variable name="apos" select='"&apos;"' /> 
<xsl:choose> 
<!-- if the string contains an apostrophe... --> 
<xsl:when test='contains($string, $apos)'> 
<!-- ... give the value before the apostrophe... -->
 <xsl:value-of select="substring-before($string, $apos)" />
 <!-- ... the escaped apostrophe ... --> 
<xsl:text>\'</xsl:text>
 <!-- ... and the result of applying the template to the string after the
apostrophe -->
 <xsl:call-template name="escape-apos">
 <xsl:with-param name="string" select="substring-after($string, $apos)" />
 </xsl:call-template>
 </xsl:when> 
<!-- otherwise... -->
 <xsl:otherwise> 
<!-- ... just give the value of the string -->
 <xsl:value-of select="$string" /> 
</xsl:otherwise> 
</xsl:choose> 
</xsl:template> 



 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.