开发者

XSL - Escaping an apostrophe during xsl:when test

开发者 https://www.devze.com 2023-04-10 08:31 出处:网络
I have the following code which appears to be failing. <xsl:when test=\"$trialSiteName = \'Physician&apos;s Office\'\"&开发者_如何学Gogt;

I have the following code which appears to be failing.

<xsl:when test="$trialSiteName = 'Physician&apos;s Office'"&开发者_如何学Gogt;

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.


Much more simple -- use:

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


  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')">
    


&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


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;">
0

精彩评论

暂无评论...
验证码 换一张
取 消