[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: A shorter way to test for position?

Subject: RE: A shorter way to test for position?
From: Scott Trenda <Scott.Trenda@xxxxxxxx>
Date: Thu, 10 May 2012 09:13:28 -0500
 RE: A shorter way to test for position?
      <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@xxxxxxxxxxxxxx] 
Sent: Thursday, May 10, 2012 8:58 AM
To: 'xsl-list@xxxxxxxxxxxxxxxxxxxxxx'
Subject:  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>

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.