Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 16th, 2008, 05:37 PM
Authorized User
 
Join Date: Jul 2008
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to cut a substring

for example i have two string "sendApplicationToManager" and "Manager",we need to compare them,if first string contains second string ,cut the matched string,the first string would turn out to be "sendApplicationTo".i tried to use translate(string 1,string2 ,'') ,but the result is not what i want.it turned into "sdApplicatioTo".
help me ,thanks.

 
Old July 17th, 2008, 01:18 AM
Authorized User
 
Join Date: May 2008
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default

if the second pattern supposed to be only at the end of the first pattern, you can use
Code:
substring-before(first_str, second_str)
 
Old July 17th, 2008, 06:29 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

translate() is quite inappropriate here, it converts individual characters.

You basically seem to want the logic

if contains($a, $b)
then concat(substring-before($a, $b), substring-after($a, $b)
else (:I suspect:) $a

(except that you'll have to apply that recursively if you want to eliminate multiple occurrences of $b).

In 2.0 you can use the replace() function.



Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Form Short cut mateenmohd Access 2 November 20th, 2007 05:30 AM
Right click cut/copy problem liesmakj Excel VBA 1 July 31st, 2007 09:21 AM
asp cut crmpicco Classic ASP Basics 5 April 1st, 2005 07:36 AM
cut it up crmpicco VB How-To 1 March 3rd, 2005 01:57 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.