RE: XPath 1.0: Literal with both ' and "?
"Kay, Michael" <[email protected]> Sat, 17 Jan 2004 00:30:01 +0100
| Newsgroups | gmane.text.xml.xpath.general |
|---|---|
| Message-ID | <[email protected]> |
This is a well-known limitation in the XPath 1.0 specification.
XPath 2.0 fixes it by allowing the delimiting quote to be doubled, so
you can write
'Tom said, "Why can''t I read?"'
In XPath 1.0, you can do it with concat():
concat("Tom said, ", '"', "Why can't I read?", '"')
There are unlikely to be any further errata published on XPath 1.0.
Apart from anything else, this is not an error in the spec, merely poor
language design.
Michael Kay
> -----Original Message-----
> From: [email protected]=20
> [mailto:[email protected]] On Behalf Of Perry A. Caro
> Sent: 16 January 2004 22:30
> To: [email protected]
> Cc: caro
> Subject: XPath 1.0: Literal with both ' and "?
>=20
>=20
>=20
> Production [29] of the XPath 1.0 spec says:
>=20
> [29] Literal ::=3D '"' [^"]* '"' =20
> | "'" [^']* "'"=20
>=20
> Given that, how do I form a literal that has both ' and " in=20
> it? For example, I want to search for an attribute whose=20
> value is an excerpt from some dialog:
>=20
> Tom said, "Why can't I read?"
>=20
> In XML, this might be represented as:
>=20
> <excerpt text=3D'Tom said, "Why can't I read?"'/>
>=20
> How would I form a predicate in XPath 1.0 that would match=20
> the value of the text attribute?
>=20
> I think this might be a bug in the specification, but I=20
> didn't see any mention of it in the Errata.
>=20
> Perry A. Caro
> Adobe Systems Incorporated
>=20
>=20