8

I have the following code which appears to be failing.

<xsl:when test="$trialSiteName = 'Physician&apos;s Office'">

Also, visual studio is complaining saying

"Expected end of expression, found 's"

How am I supposed to escape the character?


XSLT v1.0. Apache XSL-FO processor.
P.Brian.Mackey
  • 41,438
  • 63
  • 228
  • 337
  • Could your problem be related to http://stackoverflow.com/questions/646194/xsl-character-escape-problem ? If so, try: &apos; – Dan Sep 30 '11 at 17:16
  • @Dan Lehmann - That did not work. I don't think those issues are the same. – P.Brian.Mackey Sep 30 '11 at 17:24
  • As a workaround, I am going to remove this character in C# before passing it into the XSLT processor. This won't work for all situations so I will leave this question open. – P.Brian.Mackey Sep 30 '11 at 17:31

4 Answers4

9

Much more simple -- use:

   <xsl:when test="$trialSiteName = &quot;Physician&apos;s Office&quot;">
Dimitre Novatchev
  • 235,605
  • 26
  • 291
  • 421
7
  1. Declare a variable:

    <xsl:variable name="apos" select='"&apos;"'/>
    
  2. Use the variable like this in the <xsl:when> clause:

    <xsl:when test="$trialSiteName = concat('Physician', $apos, 's Office')">
    
mzjn
  • 45,711
  • 11
  • 120
  • 232
1

in between &quot; you can add what ever special characters you want.

<xsl:when test="$trialSiteName = &quot;Physician's what ever special charactors plainly add Office&quot;">
Prageeth godage
  • 3,753
  • 3
  • 26
  • 42
1

&apos; works for XPath 1.0. If you are using XSLT 2.0 with XPath 2.0 try double apostrophe:

<xsl:when test="$trialSiteName = 'Physician''s Office'">

Look for a full explanation by Dimitre Novatchev in his answer Escape single quote in xslt concat function

Community
  • 1
  • 1
Phillip Kovalev
  • 2,429
  • 21
  • 23