In XML / XSLT, you don't escape backslash characters.
- In XML, you can use entity references.
- In XSLT, you can use entity and variable references.
The problem with the apostrophe inside your concat lines is that the XML parser loading XSLT will expand it before concat is evaluated by the XSLT engine; therefore, you cannot use an entity reference for an apostrophe character if it is not enclosed in double quotes (or entity references for double quotes, as demonstrated by the answer of Dimitry Novachev).
- Use the
" object reference for double quotation marks. " - Create a variable for the apostrophe character and specify the variable as one of the concat () components
Used in the context of XSLT:
<xsl:variable name="apostrophe">'</xsl:variable> <xsl:value-of select="concat( 'this is; "a sample', //XML_NODE, '"; "using an apostrophe ', $apostrophe, ' in text"' )" />
If you need a 100% XPath solution that avoids the use of XSLT variables, then it is best to respond to a Dimitre request.
If you're worried about how easy it is to read, understand, and support, then Michael Kay’s suggestion to use XSLT variables for quotation and apostrophe might be better.
Mads Hansen Jan 09 2018-12-12T00: 00Z
source share