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
  • 43,228
  • 68
  • 238
  • 348
  • 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
  • 240,661
  • 26
  • 293
  • 431
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
  • 48,958
  • 13
  • 128
  • 248
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
  • 4,054
  • 3
  • 29
  • 45
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,479
  • 22
  • 23