tags:

views:

21

answers:

1

Hi I have this code

<xsl:choose>
 <xsl:when test="string-length(externalurl) &gt; 0">
  <xsl:attribute name="href">
   <xsl:value-of select="externalurl" />
  </xsl:attribute>
 </xsl:when>
 <xsl:otherwise>
  <!--<xsl:value-of select="externalurl" />-->
 </xsl:otherwise>
    </xsl:choose>

Now the page path gets appended to the externalurl value like:

http://www.site.com/pages/www.externalurl.com

I just want to set www.externalurl.com to the href. How do I do this? Thanks.

A: 

I think you need this:

<xsl:attribute name="href">
  <xsl:if test="not(contains(externalurl, '://'))">http://&lt;/xsl:if&gt;
  <xsl:value-of select="externalurl" />
</xsl:attribute>
Tomalak
thanks for the answer. Now what about if external url already had http://? I just need to get rid of the page path.
SajmiraZ
@SajmiraZ: If the externalurl already contains the `http://` then you don't include another one, of course. See changed answer.
Tomalak
Thanks for the answer. ^_^
SajmiraZ