473,386 Members | 1,943 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Deleteing all characters in a string until certain character....

Ok so I have an xml file that list image urls like this....

Expand|Select|Wrap|Line Numbers
  1. <imageurl>http://www.tirerack.com/images/tires/kumho/ku_victoracer_s.jpg</imageurl>
I would like to be able to use xslt to transform it to this....

Expand|Select|Wrap|Line Numbers
  1. <imageurl>ku_victoracer_s.jpg</imageurl>
I tried using a substring, but it just removes it from the first slash, and since the url has a couple slashes in i, that doesnt work. How can I do this?
Jun 28 '08 #1
1 1736
jkmyoung
2,057 Expert 2GB
Should be something like this recursive template.
Expand|Select|Wrap|Line Numbers
  1. <xsl:template match="imageurl">
  2. <xsl:copy>
  3.        <xsl:call-template name="removeUntilLast">
  4.          <xsl:with-param name="str" select="."/>
  5.          <xsl:with-param name="searchStr" select="'/'"/>
  6.        </xsl:call-template>
  7. </xsl:copy>
  8. </xsl:template>
  9.  
  10. <xsl:template name="removeUntilLast">
  11.    <xsl:param name="str"/>
  12.    <xsl:param name="searchStr" select="'/'"/> <!-- cannot be blank -->
  13.    <xsl:choose>
  14.      <xsl:when test="contains($str, $searchStr))">
  15.        <xsl:call-template name="removeUntilLast">
  16.          <xsl:with-param name="str" select="substring-after($str, $searchStr)"/>
  17.          <xsl:with-param name="searchStr" select="$searchStr"/>
  18.        </xsl:call-template>
  19.      </xsl:when>
  20.      <xsl:otherwise><xsl:value-of select="$str"/></xsl:otherwise>
  21.    </xsl:choose>
  22. </xsl:template>
  23.  
Jul 2 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

17
by: Pikkel | last post by:
i'm looking for a way to replace special characters with characters without accents, cedilles, etc.
15
by: Jeannie | last post by:
Hello group! I'm in Europe, traveling with my laptop, and I don't any compilers other than Borland C++ 5.5. available. I also don't have any manuals or help files available. Sadly, more...
8
by: Ess355 | last post by:
Hi, In the debugger at run time, characters like é are not recognised by their normal ASCII number, but something like -8615722... . I've seen this number before, it means "rubbish" right? So...
11
by: santosh | last post by:
Hi, A book that I'm currently using notes that the fgets() function does not return until Return is pressed or an EOF or other error is encountered. It then at most (in the absence of...
11
by: Ron L | last post by:
I have a barcode scanner which uses a "keyboard wedge" program so that the data it scans comes through as if it was typed on a keyboard. I am trying to have the data in the barcode be displayed in...
0
by: Janusz Nykiel | last post by:
I've stumbled upon unexpected behavior of the .NET 2.0 System.Xml.XmlWriter class when using it to write data to a binary stream (System.IO.Stream). If the amount of data is less than a certain...
6
by: Phil Barber | last post by:
I am using Regex to validate a file name. I have everything I need except I would like the dot(.) in the filename only to appear once. My question is it possible to allow one instance of character...
26
by: Brad | last post by:
I'm writing a function to remove certain characters from strings. For example, I often get strings with commas... they look like this: "12,384" I'd like to take that string, remove the comma...
14
by: rtillmore | last post by:
Hello, I did a quick google search and nothing that was returned is quite what I am looking for. I have a 200 character hexadecimal string that I need to convert into a 100 character string. ...
13
by: Liang Chen | last post by:
Hope you all had a nice weekend. I have a question that I hope someone can help me out. I want to run a Python program that uses Tkinter for the user interface (GUI). The program allows me to type...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...

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.