?
Solved

dunbar effect

Posted on 2002-04-26
1
Medium Priority
?
298 Views
Last Modified: 2006-11-17
I am using this for-each in my xsl to create a "dunbar" effect.

I know there is a way to do this using recursion.

Please help.

<xsl:template name="_table_data">
<xsl:for-each select="ProductAvailabilityResponse/ProductAvailability">
  <xsl:variable name="pos"><xsl:value-of select="position()"/></xsl:variable>
  <xsl:variable name="IsVerified"><xsl:value-of select="ProductLineItem/ProductInfo/IsVerifiedOffer"/></xsl:variable>
  <xsl:choose>    
    <xsl:when test="($pos mod 2) = 0">
      <tr class="Even">                  
        <td class="Even">    
          <xsl:value-of select="ProductLineItem/ContactInfo/CompanyName"/>              
        </td>        
        <td class="Even">
          <xsl:if test="$IsVerified='True' or $IsVerified='true' or $IsVerified='TRUE'">
            <image src="http://www.americaii.com/images/bf/ISCP.gif"/>
          </xsl:if>
        </td>    
        <td class="EvenBold">
          <xsl:value-of select="ProductLineItem/ProductInfo/ProductId"/>    
        </td>            
        <td class="Even">
          <xsl:value-of select="ProductLineItem/ProductInfo/ProductMfg"/>    
        </td>            
        <td class="Even" align="center">
          <xsl:value-of select="ProductLineItem/ProductInfo/ProductDC"/>    
        </td>            
        <td class="Even" align="right">
          <xsl:variable name="RawQty"><xsl:value-of select="ProductLineItem/ProductInfo/ProductQty"/></xsl:variable>
          <xsl:value-of select="format-number($RawQty,'###,###,###')"/>
        </td>
        <td class="Even" align="left">
          <xsl:value-of select="ProductLineItem/ProductInfo/Description"/>    
        </td>    
      </tr>
    </xsl:when>
    <xsl:otherwise>
      <tr class="Odd">                  
        <td class="Odd">
          <xsl:value-of select="ProductLineItem/ContactInfo/CompanyName"/>    
        </td>
        <td class="Odd">
          <xsl:if test="$IsVerified='True' or $IsVerified='true' or $IsVerified='TRUE'">
            <image src="http://www.americaii.com/images/bf/ISCP.gif"/>
          </xsl:if>
        </td>    
        <td class="OddBold">
          <xsl:value-of select="ProductLineItem/ProductInfo/ProductId"/>    
        </td>            
        <td class="Odd">
          <xsl:value-of select="ProductLineItem/ProductInfo/ProductMfg"/>    
        </td>            
        <td class="Odd" align="center">
          <xsl:value-of select="ProductLineItem/ProductInfo/ProductDC"/>    
        </td>            
        <td class="Odd" align="right">
          <xsl:variable name="RawQty"><xsl:value-of select="ProductLineItem/ProductInfo/ProductQty"/></xsl:variable>
          <xsl:value-of select="format-number($RawQty,'###,###,###')"/>
        </td>    
        <td class="Odd" align="left">
          <xsl:value-of select="ProductLineItem/ProductInfo/Description"/>    
        </td>    
      </tr>
    </xsl:otherwise>
  </xsl:choose>
</xsl:for-each>
</xsl:template>
0
Comment
Question by:jerelw
1 Comment
 
LVL 23

Accepted Solution

by:
b1xml2 earned 200 total points
ID: 6973091
<xsl:template name="_table_data">
<xsl:for-each select="ProductAvailabilityResponse/ProductAvailability">
<!--holding class value-->
<xsl:variable name="class">
<xsl:choose>
<xsl:when test="position() mod 2 = 0">Even</xsl:when>
<xsl:otherwise>Odd</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!--converting text to lower case-->
<xsl:variable
  name="IsVerified"
  select="translate(ProductLineItem/ProductInfo/IsVerifiedOffer,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')"/>
<tr class="{$class}">                  
<td class="{$class}">
  <xsl:value-of select="ProductLineItem/ContactInfo/CompanyName"/>
 </td>        
<td class="{$class}">
  <xsl:if test="$IsVerified='true'">
    <image src="http://www.americaii.com/images/bf/ISCP.gif"/>
  </xsl:if>
</td>    
<td class="{$class}Bold">
  <xsl:value-of select="ProductLineItem/ProductInfo/ProductId"/>    
</td>            
<td class="{$class}">
  <xsl:value-of select="ProductLineItem/ProductInfo/ProductMfg"/>    
</td>            
<td class="{$class}" align="center">
  <xsl:value-of select="ProductLineItem/ProductInfo/ProductDC"/>    
</td>            
<td class="{$class}" align="right">
  <xsl:value-of select="format-number(ProductLineItem/ProductInfo/ProductQty,'###,###,###')"/>
</td>
<td class="{$class}" align="left">
  <xsl:value-of select="ProductLineItem/ProductInfo/Description"/>    
</td>    
</tr>
</xsl:for-each>
</xsl:template>

Regards,

Brandon Driesen
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month15 days, 12 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question