Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Sep 2008
    Posts
    37
    Thanks
    5
    Thanked 0 Times in 0 Posts

    truncate the .com in a string

    ok here we go

    I have this var

    Code:
     <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

    Code:
     <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

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

  • #2
    New Coder
    Join Date
    Sep 2008
    Posts
    37
    Thanks
    5
    Thanked 0 Times in 0 Posts
    after much time and many head poundings on the desk I got this to work. code below incase anyone needs help

    Code:
     <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>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •