Solved

dunbar effect

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

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 …
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

706 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now