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

Subject: [xsl] Can't have both " and ' in an XPath literal
From: rolf@xxxxxxxxxxxx
Date: Sun, 23 Apr 2006 02:27:38 +0200 (CEST)
As far as I see, there is no way to have both ' (') and " (")
in one XPath literal.

Example:

<doc>
  <e att="foo">foo</e>
  <e att="a&apos;&quot;b">bar</e>
  <e att="grill">grill</e>
</doc>


<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

  <xsl:template match="doc">
    <xsl:for-each select="e[@att='a&apos;&quot;b']">
      <xsl:value-of select="."/>
    </xsl:for-each>
  </xsl:template>

</xsl:stylesheet>

(Please note, that this is a constructed example, not a real problem
case. I'm interested in the general question.)

Every xslt engine (including saxon, tDOM, libxslt and xalan) I tried
with raises error on this stylesheet, and I understand why.

An XML document can have an attribute value, which containes both '
(&apos;) and " (&quot;) - the example document above is well-formed.

But as far as I see, there is no way in XPath 1.0 to write a
predicate, which selects such values, because it is not possible to
write an XPath literal which includes both of the possible delimiter
characters of an XPath literal. (A similar example could be easily
constructed for text content of an element.)

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?

rolf

Current Thread