Solved

dunbar effect

Posted on 2002-04-26
1
288 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 50 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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 …
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

790 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