Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


[xsl] How to do Control Break?

From: Jonathan_Wheelhouse@----------
To:
Date: 7/1/2002 12:37:00 AM
Hi

I've got what I call a control break problem which I could easily solve in
a procedural language but don't know how to in XSLT.

The problem is that I want to alternate a <tr bgcolor="#E3EEFB"> with a <tr
bgcolor="#D0E3F8"> for each group; a group having the same firstname and
same surname.  eg.  2 rows of Adam Awad will have #E3EEFB; the 2 rows of
Adam Hutchinson will have #D0E3F8; then the next group will have #E3##FB
and so on.
Note that the number of rows per group is not constant.

I've solved this using SQL to generate a count attribute = either 0 or 1
per group.  XSLT then chooses a color based on that attribute.

However, I'm not happy with that solution because this count attribute is
not data; it's a fudge to achieve a certain presentation look.

I've read about the Muenchian method of grouping but the examples are all
about outputting something different when the group changes but not
continuing it on per entity of the group.

How would you guys do it?

Jonathan
Here's the xml, xslt and output of the current kludgey solution.

   <rs:data>
      <z:row FirstName='Adam' Surname='Awad' CurrentCountryName=''
            CurrentCityName='' CompanyName='AMP' CurrentEmailaddress
   ='Adam_Awad@xxxxxxxxxx'
            CurrentPhoneNumber='9257 3002' Count='1'/>
      <z:row FirstName='Adam' Surname='Awad' CompanyName='Compliance'
            CurrentEmailaddress='adam_awad@xxxxxxxxxx' CurrentPhoneNumber
   ='02 9257 5456'
            Count='1'/>
      <z:row FirstName='Adam' Surname='Hutchinson' CurrentCountryName=''
            CurrentCityName='' CompanyName='AMP' CurrentEmailaddress
   ='Adam_Hutchinson@xxxxxxxxxx'
            CurrentPhoneNumber='61-2-9257 5427' Count='0'/>
      <z:row FirstName='Adam' Surname='Hutchinson' CurrentCountryName=''
            CurrentCityName='' CompanyName='' CurrentEmailaddress
   ='Adam_Hutchinson@xxxxxxxxxx'
            CurrentPhoneNumber='813-5575-5400' Count='0'/>
      <z:row FirstName='Adam' Surname='Ryan' CurrentCountryName=''
            CurrentCityName='' CompanyName='AMPBanking' CurrentEmailaddress
   ='Adam_Ryan@xxxxxxxxxxxxxxxxx'
            CurrentPhoneNumber='0412 00 00 67' Count='1'/>
      <z:row FirstName='Adam' Surname='Ryan' CurrentCountryName=''
            CurrentCityName='' CompanyName='NPI' CurrentEmailaddress
   ='Adam_Ryan@xxxxxxxxxx'
            CurrentPhoneNumber='' Count='1'/>
   </rs:data>

ie. the xml is sorted on firstname and surname.  Note the "Count" attribute
flip flops between "0" and "1" when firstname and surname change.

The following XSL

    <xsl:for-each select="xml/rs:data/z:row">
       <xsl:choose>
      <xsl:when test="@Count=1">
           <tr bgcolor="#E3EEFB">
           <td><font class="FontBlack"><xsl:value-of select="@FirstName"
/></font></td>
           <td><font class="FontBlack"><xsl:value-of select="@Surname"
/></font></td>
           <td><font class="FontBlack"><xsl:value-of select="
@CurrentCityName" /></font></td>
           <td><font class="FontBlack"><xsl:value-of select="
@CurrentCountryName" /></font></td>
           <td><font class="FontBlack"><xsl:value-of select="@CompanyName"
/></font></td>
           <td><font class="FontBlack"><xsl:value-of select="
@CurrentEmailaddress" /></font></td>
           <td><font class="FontBlack"><xsl:value-of select="
@CurrentPhoneNumber" /></font></td>
           </tr>
         </xsl:when>
         <xsl:otherwise>
           <tr bgcolor="#D0E3F8">
           <td><font class="FontBlack"><xsl:value-of select="@FirstName"
/></font></td>
           <td><font class="FontBlack"><xsl:value-of select="@Surname"
/></font></td>
           <td><font class="FontBlack"><xsl:value-of select="
@CurrentCityName" /></font></td>
           <td><font class="FontBlack"><xsl:value-of select="
@CurrentCountryName" /></font></td>
           <td><font class="FontBlack"><xsl:value-of select="@CompanyName"
/></font></td>
           <td><font class="FontBlack"><xsl:value-of select="
@CurrentEmailaddress" /></font></td>
           <td><font class="FontBlack"><xsl:value-of select="
@CurrentPhoneNumber" /></font></td>
           </tr>
         </xsl:otherwise>
       </xsl:choose>
    </xsl:for-each>

produces

<tr bgcolor="#E3EEFB">
<td><font class="FontBlack">Adam</font></td>
<td><font class="FontBlack">Awad</font></td>
<td><font class="FontBlack"></font></td>
<td><font class="FontBlack"></font></td>
<td><font class="FontBlack">AMP</font></td>
<td><font class="FontBlack">Adam_Awad@xxxxxxxxxx</font></td>
<td><font class="FontBlack">9257 3002</font></td>
</tr>
<tr bgcolor="#E3EEFB">
<td><font class="FontBlack">Adam</font></td>
<td><font class="FontBlack">Awad</font></td>
<td><font class="FontBlack"></font></td>
<td><font class="FontBlack"></font></td>
<td><font class="FontBlack">Compliance</font></td>
<td><font class="FontBlack">adam_awad@xxxxxxxxxx</font></td>
<td><font class="FontBlack">02 9257 5456</font></td>
</tr>
<tr bgcolor="#D0E3F8">
<td><font class="FontBlack">Adam</font></td>
<td><font class="FontBlack">Hutchinson</font></td>
<td><font class="FontBlack"></font></td>
<td><font class="FontBlack"></font></td>
<td><font class="FontBlack">AMP</font></td>
<td><font class="FontBlack">Adam_Hutchinson@xxxxxxxxxx</font></td>
<td><font class="FontBlack">61-2-9257 5427</font></td>
</tr>
<tr bgcolor="#D0E3F8">
<td><font class="FontBlack">Adam</font></td>
<td><font class="FontBlack">Hutchinson</font></td>
<td><font class="FontBlack"></font></td>
<td><font class="FontBlack"></font></td>
<td><font class="FontBlack"></font></td>
<td><font class="FontBlack">Adam_Hutchinson@xxxxxxxxxx</font></td>
<td><font class="FontBlack">813-5575-5400</font></td>
</tr>
<tr bgcolor="#E3EEFB">
<td><font class="FontBlack">Adam</font></td>
<td><font class="FontBlack">Ryan</font></td>
<td><font class="FontBlack"></font></td>
<td><font class="FontBlack"></font></td>
<td><font class="FontBlack">AMPBanking</font></td>
<td><font class="FontBlack">Adam_Ryan@xxxxxxxxxxxxxxxxx</font></td>
<td><font class="FontBlack">0412 00 00 67</font></td>
</tr>
<tr bgcolor="#E3EEFB">
<td><font class="FontBlack">Adam</font></td>
<td><font class="FontBlack">Ryan</font></td>
<td><font class="FontBlack"></font></td>
<td><font class="FontBlack"></font></td>
<td><font class="FontBlack">NPI</font></td>
<td><font class="FontBlack">Adam_Ryan@xxxxxxxxxx</font></td>
<td><font class="FontBlack"></font></td>
</tr>





This email message and any accompanying attachments may contain
information that is confidential and is subject to legal privilege. If you are not
the intended recipient, do not read, use, disseminate, distribute or copy this 
message or attachments. If you have received this message in error, please 
notify the sender immediately and delete this message. Any views expressed
in this message are those of the individual sender, except where the sender
expressly, and with authority, states them to be the views of AMP. Before 
opening any attachments, please check them for viruses and defects.



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent