xsl-list
[Top] [All Lists]

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

2009-11-20 16:53:12
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(_at_)CraneSoftwrights(_dot_)com
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal


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