How to substring url in xslt

Posted on 2010-01-03
Last Modified: 2013-11-18
I have a column in xslt called $fieldvalue which is a url field. I want to get a specific string in the URL and group by that value.

For example my URL is :

I want to get always the value from the URL after, which in the above case is 'hello' and ignore the "/tools/image". The URL changes all the time but I want to grab the value after "GET THIS VALUE"/"IGNORE THE REST".
And I want to group by other value by the above string that I got from the URL.



						<xsl:when test="$fieldtype='url'">

							<a href="{$fieldvalue}"><xsl:value-of select="$fieldvalue" />



						<xsl:when test="$fieldtype='user'">

							<xsl:value-of select="$fieldvalue" disable-output-escaping="yes" />



							<xsl:value-of select="hithighlightedproperties/HHTitle/text()" />



Open in new window

Question by:vmandem
    LVL 60

    Expert Comment

    by:Geert Bormans
    }"><xsl:value-of select="substring-before(substring-after($fieldvalue, ''), '/')"/>
    LVL 60

    Expert Comment

    by:Geert Bormans
    loose the }"> from my answer above

    Author Comment

    I noticed in my requirements sometimes in my url that I look for some names and want to grab that string and group by that string will all the results. For example I look for a string called Accountant in the URL: Then the above substring scenario does not work. How to deal with that suituation. I have several cases where I know the keywords and want to check in the URL if that keyword exist and grab that string and group by the column. I can post my XSLStylesheet if you would like. please let me know.
    LVL 60

    Accepted Solution

    Your exact requirement is not clear to me, I must say,
    but I believe you can get what you need by a combination of
    - substring-before
    - substring-after
    - contains()

    contains returns true if the string in the first argument contains the string in the second argument

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Suggested Solutions

    I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
    I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
    Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now