xsl-list
[Top] [All Lists]

[xsl] RE: A shorter way to test for position?

2012-05-10 10:13:51
      <div class="cat_module">
        <xsl:if test="position() mod 3 = 0">
          <xsl:attribute name="style">border-right: none;</xsl:attribute>
        </xsl:if>

        <div class="cat_image">
          <a href="{descendant::link}">
            <img src="{descendant::image}" alt=""/>
          </a>
        </div>

        <div class="cat_desc">
          <h2>
            <a href="{descendant::link}">
              <xsl:value-of select="@display_name"/>
            </a>
          </h2>
        </div>

        <a href="{descendant::link}">
          <span>Shop Now</span>
        </a>
      </div>

~ Scott


-----Original Message-----
From: Dan Acuff [mailto:dacuff(_at_)suresource(_dot_)com] 
Sent: Thursday, May 10, 2012 8:58 AM
To: 'xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com'
Subject: [xsl] A shorter way to test for position?

Isn't there a shorter way to add a style attribute to the <div 
class="cat_module"> element than doing a choose/when/otherwise like I have done 
below?
This will work but if there is shorthand I want to learn it.
Help Much appreciated.

    <xsl:choose>
    <xsl:when test="position() mod 3 = 0">
      <div class="cat_module" style="border-right: none;">        
      <div class="cat_image">
       <a href="{descendant::link}"><img src="{descendant::image}" alt=""/></a>
      </div>
    
      <div class="cat_desc">
        <h2>
                   <a href="{descendant::link}"><xsl:value-of 
select="@display_name"/></a>
                  </h2>
           </div>
            
       <a href="{descendant::link}">
       <span>Shop Now</span>
      </a>
     </div>
    </xsl:when>
    <xsl:otherwise>
      <div class="cat_module">
        <div class="cat_image">
          <a href="{descendant::link}">
            <img src="{descendant::image}" alt=""/>
          </a>
        </div>

        <div class="cat_desc">
          <h2>
            <a href="{descendant::link}">
              <xsl:value-of select="@display_name"/>
            </a>
          </h2>
        </div>

        <a href="{descendant::link}">
          <span>Shop Now</span>
        </a>
      </div>
    </xsl:otherwise>
    </xsl:choose>



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>