Escape single quote in xslt concat function Escape single quote in xslt concat function javascript javascript

Escape single quote in xslt concat function


In XPath 1.0:

You can use the built-in entities ' and "

In XSLT 1.0:

Alternatively, you can define your $Q and $APOS variables (put the content (the literal " or the literal ' character) in the body of the xsl:variable, not in the select attribute).

In XPath 2.x (this also means XSLT 2.x and XQuery 1.x)

Simply escape an apostrophe by entering two adjacent apostrophes, escape a quote by entering two adjacent quotes, as defined by the XPath 2.0 language


To expand on Dimitre's answer, you can use this solution in XSLT:

<xsl:variable name="apos">'</xsl:variable><xsl:value-of select="concat('process[@Ref=',$apos,$ID,$apos,']')"></xsl:value-of>


Use &apos;?

<xsl:value-of select="concat('process[@Ref=&apos;',$ID,'&apos;]')"></xsl:value-of>

Edit: See Dimitre's answer for a better solution.