Re: [xsl] How to select for ' in XPATH?

Subject: Re: [xsl] How to select for ' in XPATH?
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Wed, 05 Aug 2009 12:16:48 -0700
At 2009-08-05 20:36 +0200, Hermann Stamm-Wilbrandt wrote:
There was a typo in my last email, '%22' works for &quot;
and '%27' does not work for &apos;
( the %22 gets converted to &quot; character by unescape(s) )

This is not true for XPath. The "%" notation is not recognized.

> you are left with breaking up the string into components that
> contain no single quote and components that contain a single quote and
> then concatenate them e.g. if the selection on the page is e.g.
> What's that?
> you use
> "//*[contains(., concat('What', \"'\", ' that?')"

Good idea to break this up and concatenate.
But the basic problem remains, how to match for the single &quot; ?

\"'\" does not work :-(

In XSLT 2:

"//*[contains(., concat('What','''',' that?'))]"

or more simply just:

"//*[contains(., 'What'' that?')]"

In XSLT 1:

"//*[contains(., 'What&#x27; that?)]"

But be careful because the above selects the document element which will contain all text in its value.

> Implementing breaking up the string with JavaScript should be possible
>although having to stuff all that into a bookmarklet might get ugly.
Perhaps this might get ugly, but not without a solution to match for
the single &quot; character ...

&quot; is " - the double quote

&apos; is ' - the apostrophe (single quote)

I hope this helps.

. . . . . . . . . . . . . Ken

-- Crane Softwrights Ltd. Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video Video lesson: Video overview: G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Male Cancer Awareness Nov'07 Legal business disclaimers:

Current Thread