Subject: Re: [xsl] comparison of strings having single quote From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Fri, 15 Feb 2002 10:59:56 +0000 |
Hi Phani, > I have the following xml & xsl files. I would like to get the ARTIST > which has only - Sri's -. How to do it. The main problem is with the > single quote handling. The when match condition given below fails. I notice that you're using WD-xsl rather than XSLT. You should upgrade to using XSLT as soon as you can. Details are in the MSXML FAQ at http://www.netcrucible.com/. The single-quote problem will occur in XSLT as well, though. Let's concentrate first on the XPath that you want to create. You've tried: ARTIST = 'Sri's' but this doesn't work because the single quote in the middle of the string is interpreted as ending the string. There's no way to escape characters in XPath, but you can use either single or double quotes around literal strings. So you have to do: ARTIST = "Sri's" That's the XPath that you want. Now you have to worry about putting that into an attribute value in XSLT. XSLT is XML, so you can't just do: test="ARTIST = "Sri's"" because the double quote that you need in the XPath expression will match the double quote that starts the attribute value, and you'll get an error. Fortunately, there *is* a ways of escaping characters in XML, so you can get around this problem by escaping the double quotes in the attribute value with " as follows: test="ARTIST = "Sri's"" Alternatively, you can use single quotes around the attribute value rather than double quotes. If you use single quotes, then the single quote in the attribute value has to be escaped with ' as follows: test='ARTIST = "Sri's"' Either of these will work. Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] comparison of strings having , Pemmaraju Phani Kuma | Thread | [xsl] Q on incremental processing a, Enke Michael |
Re: [xsl] local-name of attribute v, Trevor Nash | Date | [xsl] Q on incremental processing a, Enke Michael |
Month |