XSL / XPATH: how to test if text contains apostrophe

M

Michael

Hallo,

for some reasons of calling functions with parameters, i have to test
if a text-node contains an apostrophe. My problem is that i cannot
write something like <xsl:if test="contains(., ''')">.
So i tried using entities or escaping, like that:
<xsl:if test="contains(., '&apos;')">
or:
<xsl:if test="contains(., '\'')">
but both didn't work.
Further problem is that i have to translate these apostrophes into
escaped ones like \' (<xsl:value-of select="translate(., '&apos;',
'\&apos;')" /> or <xsl:value-of select="translate(., '\'', '\'')" />).

Is there any way solving this problem.
Thanks a lot for your help.

Michael
 
M

Martin Honnen

Michael wrote:

So i tried using entities or escaping, like that:
<xsl:if test="contains(., '&apos;')">

Further problem is that i have to translate these apostrophes into
escaped ones like \' (<xsl:value-of select="translate(., '&apos;',
'\&apos;')" /> or <xsl:value-of select="translate(., '\'', '\'')" />).

translate replaces a single character with a single character if you
want to have some string replacement then you need to write your own
recursive template doing that or you can use one of the implementations
around on the web e.g.
<http://www.exslt.org/str/functions/replace/index.html>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top