Re: [xsl] single quotes..problem.

Subject: Re: [xsl] single quotes..problem.
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Thu, 4 Jan 2001 13:20:52 +0000
Hi Sachi,

>     I am trying to send a string of like this "B's Beverages" to filter
> condition in XSL from javascript.
>    eg.
>      someobject.selectNodes("root/element["+selval+"]");
>     selval - is the string which I pass as  "@ShipName=B's Beverages".But it
> is not possible. any idea to slove this probelm.

The string that you pass as an argument into .selectNodes needs to be
a valid XPath. The string "B's Beverages" needs to be surrounded by
quotes so that the XPath processor recognises it as a string. Because
of the apostrophe in B's Beverages, the valid XPath that you need to
use is:

  root/element[@ShipName = "B's Beverages"]

So, selval needs to be set to the string:

  @ShipName = "B's Beverages"

Within the Javascript, you need to wrap that string in quotes so that
the Javascript processor can recognise it as a string. Within
Javascript, you have to escape single and double quotes within a
string using '\' so that they're not recognised as quotes. So, when
you set selval, use:

  selval = '@ShipName = \"B\'s Beverages\"';

or:

  selval = "@ShipName = \"B\'s Beverages\"";

I hope that helps,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread