...

View Full Version : truncate the .com in a string



Mthor
03-31-2010, 08:38 PM
ok here we go

I have this var


<xsl:variable name="reseller" select="/response/parameters/currentpath/level[id=2]/name"/>

it returns either "example" or "example.com"

I am displaying an img based on what is coming back


<xsl:if test="$reseller != 'example'">
<img src="Styles/Intercall/images/poweredby.png" />
</xsl:if>

as you can see my problem is tha sometimes i receive example and sometimes example.com

I need a way to truncate the .com if it gets returned at all in the var below


<xsl:variable name="reseller" select="/response/parameters/currentpath/level[id=2]/name"/>

thanks

Mthor
03-31-2010, 09:54 PM
after much time and many head poundings on the desk I got this to work. code below incase anyone needs help


<xsl:variable name="resellerName" select="/response/parameters/currentpath/level[id=2]/name"/>
<xsl:variable name="reseller">
<xsl:choose>
<xsl:when test="contains($resellerName,'.')">
<xsl:value-of select="substring-before($resellerName,'.')" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$resellerName"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum