RE: [xsl] Can't have both " and ' in an XPath literal

Subject: RE: [xsl] Can't have both " and ' in an XPath literal
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Sun, 23 Apr 2006 08:50:04 +0100
> To all of my knowledge, the XPath 1.0 syntax has no escaping 
> mechanism for literal delimiters at all. 
> 
> Do I miss something? If no, is this problem still valid for XPath 2.0?

XPath 2.0 allows the delimiter of a string literal to be doubled within the
literal:

xsl:if test='($x = "He said, ""I don&apos;t""")'>...

In XSLT 1.0 my usual approach is to use variables

<xsl:variable name="quot">"</xsl:variable>
<xsl:variable name="apos">'</xsl:variable>
<xsl:if test="$x = concat('He said, ', $quot, 'I don', $apos, 't',
$quot)">...

Michael Kay
http://www.saxonica.com/

Current Thread