Solved

dunbar effect

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Nessus Scan 1 71
XSLT list item selection criteria not working 12 30
XSLT Help 12 33
XML XSL Message 3 22
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 …
The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

821 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