473,569 Members | 2,916 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

URL string manipulation

Hello, I'm struggling with an image mechanism I'm trying to build
which basically manipulates a URL string.

This is the sort URL that is gained from an InfoPath form

https://xxx-xxx.xxx.xxx.com/content/...xx/xxx/xxx.jpg

However I need to manipulate it so it also displays like this;

https://xxx-xxx.xxx.xxx.com/content/..._t/xxx_JPG.jpg

As you can see it adds an '_t' and a '_JPG' into the URL string.

This is where I am up to now, which from what I can see adds a '_' in
front of the URL.

_______________ _______________ _______________ _______________ _______________ ___________

<xsl:output method="html"/>
<xsl:template match="/">
<xsl:variable name="url" select="my:myFi elds/my:URL"/>
<xsl:call-template name="truncate" >
<xsl:with-param name="string" select="$url"/>
</xsl:call-template>
</xsl:template>

<xsl:template name="truncate" >
<xsl:param name="string"/>
<xsl:param name="counter" select="3"/>
<xsl:if test="$string!= '' and $counter!=0">
<xsl:text>_</xsl:text>
<xsl:choose>
<xsl:when test="contains( $string, ' ')">
<xsl:value-of select="substri ng-before($string, '/')"/>
<xsl:call-template name="truncate" >
<xsl:with-param name="string" select="substri ng-
after($string, '/')"/>
<xsl:with-param name="counter" select="$counte r - 1"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwis e>
<xsl:value-of select="$string "/>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:template>

_______________ _______________ _______________ _______________ _______________ _______________

Please advise or show me some useful code.

Many thanks in advance

Sep 25 '07 #1
1 2968
If you need to do more complicated string manipulation that may involve
iterating through the string or doing things the basic functions can't
easily handle, check out the relevant sections of the XSLT FAQ. In
particular, see the techniques described in

http://www.dpawson.co.uk/xsl/sect2/StringReplace.html
and
http://www.dpawson.co.uk/xsl/sect2/N7240.html

(Note that this complexity is necessary only because you want to replace
"the last instance of /", and the basic XPath operations don't appear to
include a last-position-of function.)

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
Sep 25 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2267
by: Dim | last post by:
I found that C# has some buggy ways to process string across methods. I have a class with on global string var and a method where i add / remove from this string Consider it a buffer... with some values and separators class { private string globalvar = ""; private void manipulate (whattodo ) //substring, join, etc....
32
14783
by: tshad | last post by:
Can you do a search for more that one string in another string? Something like: someString.IndexOf("something1","something2","something3",0) or would you have to do something like: if ((someString.IndexOf("something1",0) >= 0) || ((someString.IndexOf("something2",0) >= 0) ||
29
4293
by: zoro | last post by:
Hi, I am new to C#, coming from Delphi. In Delphi, I am using a 3rd party string handling library that includes some very useful string functions, in particular I'm interested in BEFORE (return substring before a pattern), AFTER (return substring after a pattern), and BETWEEN (return substring between 2 patterns). My questions are: 1. Can...
4
3476
by: WaterWalk | last post by:
Hello, I'm currently learning string manipulation. I'm curious about what is the favored way for string manipulation in C, expecially when strings contain non-ASCII characters. For example, if substrings need be replaced, or one character needs be changed, what shall I do? Is it better to convert strings to UCS-32 before manipulation? But...
10
1760
by: micklee74 | last post by:
hi if i have a some lines like this a ) "here is first string" b ) "here is string2" c ) "here is string3" When i specify i only want to print the lines that contains "string" ie the first line and not the others. If i use re module, how to compile the expression to do this? I tried the re module and using simple
5
7471
by: Niyazi | last post by:
Hi, Does anyone knows any good code for string manipulation similar to RegularExpresion? I might get a value as string in a different format. Example: 20/02/2006 or 20,02,2006 or 20.02.2006 etc... And I want to replace the /,.etc character with - (as 20-02-2006)
3
1555
by: crprajan | last post by:
String Manipulation: Given a string like “This is a string”, I want to remove all single characters( alphabets and numerals) like (a, b, 1, 2, .. ) . So the output of the string will be “This is string” This is very urgent. Please help
7
2094
Frinavale
by: Frinavale | last post by:
I currently have a .NET application that has an object which passes a string (a connection string) as a parameter to another object that does database manipulation. This string isn't stored anywhere else and is only used by this behind-the-scenes object to provide the database manipulation object with a connection string. Does my connection...
3
3553
by: frankeljw | last post by:
I have 2 Java strings 1st String is a series of names, colons, and numbers ie) Name1:13:Name2:4526:Name3:789:Name4:3729:Name5:6:Name6:44 2nd String is a name ie) Name2 I need to get the number associated with that name.
22
2579
by: mann_mathann | last post by:
can anyone tell me a solution: i cannot use the features in standard c++ string classgh i included the string.h file but still its not working.
0
7693
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7605
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7917
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8118
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7665
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5501
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5217
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.