RE: [xsl] Replace function and apostrophes

Subject: RE: [xsl] Replace function and apostrophes
From: "Andrew Welch" <ajwelch@xxxxxxxxxxxxxxx>
Date: Thu, 17 Feb 2005 15:21:55 -0000
> 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(., "&apos;", "\\&apos;")'

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

Thanks again,

Current Thread