Search code examples
c#xmlxsltxpathextension-objects

Special char in Xslt file


I'm calling a method of my extension object.

Here is my method's signature:

public string GetValue(string xPath) { }

And here is the place I call it in my Xslt file:

<xsl:value-of select ="crn:GetValue('courier:_application/base:_entity/loan:_applicant/base:_entity/person:_phones/base:SmartRefOfPhoneeJDvviUx[base:_entity/contact:_isMobile/base:_underlyingValue='true']/base:_entity/contact:_secondaryPrefix/base:_underlyingValue')"/>

Because of the part

[base:_entity/contact:_isMobile/base:_underlyingValue='true']

contains ' chars, I'm getting an error

"Expected token ')', found 'true'. ...isMobile/base:_underlyingValue=' -->true<-- ']/base:_entity/contact:_extensi..."

I couldn't find an escape char for X-path. Do you have any suggestions?


Solution

  • You can use XSLT/XML escape mechanisms i.e.

    <xsl:value-of select ="crn:GetValue(&quot;courier:_application/base:_entity/loan:_applicant/base:_entity/person:_phones/base:SmartRefOfPhoneeJDvviUx[base:_entity/contact:_isMobile/base:_underlyingValue='true']/base:_entity/contact:_secondaryPrefix/base:_underlyingValue&quot;)"/>