[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: comparison of strings having single quote

Subject: Re: comparison of strings having single quote
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Fri, 1 Mar 2002 15:44:42 +0000
apos s
Hi Phani,

> I have a further problem... how are we going to handle a case where
> my string has both double quotes and single quotes. I attach my
> previous mail for your reference. In that example if I have to check
> for -----S"RI's---- how do I do it. Can you plz let me know.

For that, you have to create the string through concatenation. At the
XPath level, you need something like:

  ARTIST = concat('-----S"RI', "'", 's----')

At the XSLT level, you need to escape either the "s or 's, depending
on which you use to delimit the attribute. So you need either:

  <xsl:if test="ARTIST =
                concat('-----S&quot;RI', &quot;'&quot;, 's----')">
    ...
  </xsl:if>

Or:

  <xsl:if test='ARTIST =
                concat(&apos;-----S"RI&apos;, "&apos;", &apos;s----&apos;)'>
    ...
  </xsl:if>

Sometimes people declare a variable to hold apostrophes:

<xsl:variable name="apos" select='"&apos;"'" />

and then use that within the concatenation to make it easier to read:

  <xsl:if test="ARTIST =
                concat('-----S&quot;RI', $apos, 's----')">
    ...
  </xsl:if>

  
----

Good news for XPath 2.0 -- apparently in XPath 2.0, you'll be able to
escape double quotes or apostrophes within a string by doubling them
up. So you will then be able to do:

  ARTIST = '-----S"RI''s----'

or:

  ARTIST = "-----S""RI's----"

Cheers,

Jeni

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


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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.