By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,180 Members | 1,051 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,180 IT Pros & Developers. It's quick & easy.

URL string manipulation

P: n/a
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

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

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:myFields/my:URL"/>
<xsl:call-template name="truncate">
<xsl:with-param name="string" select="$url"/>

<xsl:template name="truncate">
<xsl:param name="string"/>
<xsl:param name="counter" select="3"/>
<xsl:if test="$string!='' and $counter!=0">
<xsl:when test="contains($string, ' ')">
<xsl:value-of select="substring-before($string, '/')"/>
<xsl:call-template name="truncate">
<xsl:with-param name="string" select="substring-
after($string, '/')"/>
<xsl:with-param name="counter" select="$counter - 1"/>
<xsl:value-of select="$string"/>

__________________________________________________ ________________________________________

Please advise or show me some useful code.

Many thanks in advance

Sep 25 '07 #1
Share this Question
Share on Google+
1 Reply

P: n/a
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

(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 discussion thread is closed

Replies have been disabled for this discussion.