Re: [xsl] How to include ' in the argument of <translate> function

Subject: Re: [xsl] How to include ' in the argument of <translate> function
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Fri, 20 Nov 2009 16:51:58 -0500
At 2009-11-20 16:46 -0500, Mak, Lucas Wing Kau wrote:
I am trying to replace the apostrophe (') with a space by the <translate> function but oXygen gave me an error message ("unmatched quote in expression") when I put &apos; in the second argument. How can I resolve that?

You aren't showing your current code for volunteers to analyze where you are going wrong.


You have to distinguish attribute delimiters from string delimiters.

For example, this should work just fine:

select='translate($old,"&apos;","")'

... because I'm using single quotes as my attribute delimiter and double quotes for my string delimiters. That choice of string delimiter allows me to embed an apostrophe in the string, which I do with the entity reference.

Remember that entity substitution happens long before the syntax analysis of the function call, so if you had:

select="translate($old,'&apos;','')"

... then you would get an error because that is *no* different from:

select="translate($old,''','')"

I hope this helps.

. . . . . . . . . Ken


-- Vote for your XML training: http://www.CraneSoftwrights.com/s/i/ Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video Video lesson: http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18 Video overview: http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18 G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal

Current Thread