Subject: Re: [xsl] escaping ampersands in replace function From: Abel Braaksma <abel.online@xxxxxxxxx> Date: Tue, 04 Sep 2007 18:59:22 +0200 |
Sorry to say
replace($l_TempString,'&','and')
get an error message stating the & must be followed by an entity reference
replace($l_TempString,'&','and') and replace($l_TempString,'&amp;','and')
the amp is not replaced.
I'm using the latest version of Saxon8 (from sourceforge).
An example of a string I'm trying to replace: A & B to A and B. So th
if $string has '&' >>> 'and' if $string has '&' >>> 'andamp;' if $string has '&&' >>> 'andampandamp;'
Cheers, -- Abel Braaksma
Quoting David Carlisle <davidc@xxxxxxxxx>:
I'm using XSLT2's replace function against a string but am having problems
escaping the ampersand.
ampersaand isn't a special character to xpath regular expressions, so you don't need to escape it so you want:
replace($l_TempString,'&','and')
then you need to put that XPath expression in a slect attribute, whenever you put a string containg & in an XMl file you need to write it as & so the xslt looks like
select="replace($l_TempString,'&','and')"
This is assuming that your input string contains a " & " if it contains " & "
then you want the XPath
replace($l_TempString,'&','and')
which would be written in an XML file such as an XSLT stylesheet as
select="replace($l_TempString,'&amp;','and')"
as the & has to be written as &
David
________________________________________________________________________
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] escaping ampersands in re, David Carlisle | Thread | [xsl] Bibtex in xml, fatma helmy |
Re: [xsl] escaping ampersands in re, David Carlisle | Date | Re: [xsl] escaping ampersands in re, Mario Madunic |
Month |