tags:

views:

25

answers:

3

Hi I am using xslt to show the links on my webpart and i have added plus image next to my link.But I would like to add some space between them. I have added ,but this is not really working. Am i missing anything here? Please find my code below.

Thanks.

    <xsl:choose>
        <!-- do _self -->
        <xsl:when test="contains(Link,'xxx')">
          <a target="_self">
            <xsl:attribute name="href">
                <xsl:value-of select="URL"/>
            </xsl:attribute>
                <xsl:value-of select="Title"/>
          </a>
        </xsl:when>
        <!-- use _blank (new browser window) -->
    <xsl:otherwise>
        <a target="_blank">
         <xsl:attribute name="href">
            <xsl:value-of select="URL"/>
         </xsl:attribute>
            <xsl:value-of select="Title"/>
        </a> 
   </xsl:otherwise>
   </xsl:choose>
   <xsl:text> </xsl:text>
   <xsl:choose>
       <xsl:when test="Description !=' ' ">
          <img class="imageclass" src="/images/plus.gif"></img>
        </xsl:when> 
   </xsl:choose>
A: 

Use padding in the imageclass class. Could you post the generated HTML?

rdkleine
+2  A: 

The xsl:text instruction is the right tool for your requeriment. As example, this stylesheet:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
    <xsl:template match="@*|node()" name="identity">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
    </xsl:template>
    <xsl:template match="a">
        <xsl:call-template name="identity"/>
        <xsl:text> </xsl:text>
    </xsl:template>
</xsl:stylesheet>

With this input:

<div>
    <a href="#">link1</a>
    <a href="#">link1</a>
    <a href="#">link1</a>   
</div>

Output:

<div><a href="#">link1</a> <a href="#">link1</a> <a href="#">link1</a> </div>
Alejandro
A: 

My understanding is that you want to produce HTML that would display white space in the browser.

If this is so, don't use spaces -- the brouser only displays one single space for a continuous sequence of spaces.

Use nonbreaking space: &#xA0;

So, instead of:

  <xsl:text>   </xsl:text>

use:

  <xsl:text>&#xA0;&#xA0;&#xA0;</xsl:text>
Dimitre Novatchev
Great! It worked for me. Thanks a lot for your help.