xsl-list
[Top] [All Lists]

Re: [xsl] Escaping single-quotes - an old chestnut I suspect but won't respond to any amount of Googling...

2007-04-04 21:28:03

<quote who="Matt Poff">
Hi,

I have an XSLT file which is generating a number of SQL statements from
an XHTML file (output method is set to "text"). I need to escape
apostrophe and quote characters in text nodes and have tried using the
code below:

    <xsl:function name="hf:escapechars" >
        <xsl:param name="currnode" />
        <xsl:variable name="apos" select='"&apos;"' />
        <xsl:variable name="quot" select="'&quot;'" />
        <xsl:variable name="backslash">\</xsl:variable>

        <xsl:value-of
select="replace($currnode,'$apos','concat($backslash,$apos))"/>
    </xsl:function>

This generates "Description: E Invalid replacement string in replace():
\ character must be followed by \ or $". How can i successfully escape
the backslash so it will output?

Have you tried the error suggestion such as :-

<xsl:variable name="backslash">\\</xsl:variable>

Gav...


Thanks for you help,
Matt

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



-- 
Gav...


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>