xsl-list
[Top] [All Lists]

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

2009-08-05 15:21:47
At 2009-08-05 20:36 +0200, Hermann Stamm-Wilbrandt wrote:
There was a typo in my last email, '%22' works for "
"/*/*/*[contains(normalize-space(.),'%22')])"
and '%27' does not work for '
( the %22 gets converted to " 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 " ?

\"'\" does not work :-(

In XSLT 2:

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

 or more simply just:

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

In XSLT 1:

  "//*[contains(., 'What' 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 " character ...

" is " - the double quote

' is ' - the apostrophe (single quote)

I hope this helps.

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


--
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
Video lesson:    http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18
Video overview:  http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18
G. Ken Holman                 mailto:gkholman(_at_)CraneSoftwrights(_dot_)com
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--