xsl-list
[Top] [All Lists]

RE: Replace function and apostrophes

2005-02-17 08:21:55

XPath 2.0 allows the delimiter of a string literal to be 
doubled withing the string, so you can write

"replace(., '''', '\\''')" 

Thanks, that's what I was looking for.

Alternatively, use

select='replace(., "'", "\\'")'

For some reason I've got an aversion for using single quote as attribute
delimiters, don't know why, I guess it's down to habit.

or define the strings as variables:

<xsl:variable name="x" as="xs:string">'</xsl:variable> 
<xsl:variable name="x" as="xs:string">\\'</xsl:variable>

select="replace(.,$x,$y)"

Although I would say this is most readable, it just seems a bit too
verbose.

Thanks again,
andrew

--~------------------------------------------------------------------
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>