<\/script>')

XSL - escaping the apostrophe during xsl: when testing

I have the following code that seems to fail.

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

In addition, the visual studio complains about the statement.

"Expected end of expression found"

How do I escape a character?




XSLT v1.0. Apache XSL-FO processor.
+6
xslt
Sep 30 '11 at 16:46
source share
3 answers

Much easier - use :

  <xsl:when test="$trialSiteName = &quot;Physician&apos;s Office&quot;"> 
+8
01 Oct 2018-11-11T00:
source share
  • Declare a variable:

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

     <xsl:when test="$trialSiteName = concat('Physician', $apos, Office')"> 
+6
Sep 30 '11 at 18:19
source share

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

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

Look for a complete explanation of Dimitry Novachev in his answer Escape single quote in concat xslt function

+1
Sep 30 '11 at 17:13
source share



All Articles