?
Solved

How to substring url in xslt

Posted on 2010-01-03
4
Medium Priority
?
642 Views
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 : http://www.test.com/hello/tools/image

I want to get always the value from the URL after http://www.test.com/, 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 http://www.test.com/ "GET THIS VALUE"/"IGNORE THE REST".
And I want to group by other value by the above string that I got from the URL.

NOTE: SAMPLE CODE SHOWN BELOW

<xsl:choose>
						<xsl:when test="$fieldtype='url'">
							<a href="{$fieldvalue}"><xsl:value-of select="$fieldvalue" />
							</a>
						</xsl:when>
						<xsl:when test="$fieldtype='user'">
							<xsl:value-of select="$fieldvalue" disable-output-escaping="yes" />
						</xsl:when>
						<xsl:otherwise>
							<xsl:value-of select="hithighlightedproperties/HHTitle/text()" />
						</xsl:otherwise>
					</xsl:choose>

Open in new window

0
Comment
Question by:vmandem
  • 3
4 Comments
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 26166706
try
}"><xsl:value-of select="substring-before(substring-after($fieldvalue, 'http://www.test.com/'), '/')"/>
0
 
LVL 60

Expert Comment

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

Author Comment

by:vmandem
ID: 26167863
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:
http://www.test.com/hello/Accountant. 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.
0
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 300 total points
ID: 26170308
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
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

578 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