|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Escaping apostrophes for use in javascript, etc. - how
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='"'"' /> <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
|
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
|

Cart








