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

RE: Contains - where contained

Subject: RE: Contains - where contained
From: "Andrew Welch" <AWelch@xxxxxxxxxxxxxxx>
Date: Mon, 26 Jan 2004 11:12:00 -0000
one string contains another

> Is there an easy way to test not only whether one strings 
> contains another, but if the position of the contains is at 
> the start  of the taret string, at the end or somewhere other 
> than  the start and the end.

To test if one string contains another:

test="contains(.,$string) 

To test if one string is at the start of another string:

test="not(string-length(normalize-space(substring-before(.,$string))))"

Combine the two:

test="contains(.,$string) and
not(string-length(normalize-space(substring-before(.,$string))))"

To do what you are asking use a choose/when with the start and end tests
first, and the middle test falling into the otherwise.

You may want to remove the normalize-space() if you would treat "hello"
and " hello" differently.  You probably also would want to translate()
to the same case before comparing as well.

andrew

 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.