[xsl] I need to eliminate the duplicate rows and extra heading at bottom of display using XSLT 1.0

Subject: [xsl] I need to eliminate the duplicate rows and extra heading at bottom of display using XSLT 1.0
From: "Love, Toni" <TLove@xxxxxxxxxx>
Date: Thu, 2 Jun 2005 10:57:29 -0500
I need to eliminate the duplicate rows and  extra heading at bottom of
display.  I was able to get help with grouping from
www.jenitennison.com,
which was very helpful.  Any additional assistance
you can give me will be
greatly appreciated.
************************************************************************
****************************
Wanted Output
Premise(s)  		
Bill Period
Days in Period
Consumption              Amount
(From - To) 
2005-01-26 -
2005-02-24  		29 	     	 Total Therm
14.5       28.66  
 
Total KWH    1333.0
62.40

Current Output

Premise(s)  		
Bill Period
Days in Period
Consumption                   Amount
(From - To) 
2005-01-26 -
2005-02-24  	        29
Total Therm       14.5           28.66  
2005-01-26 -
2005-02-24               29
Total KWH    1333.0          62.40
  
Premise(s)
Bill Period 
(From - To)                            Days in Period
Consumption
Amount
************************************************************************
***********************************

Sample XML

<?xml version="1.0" ?> 
-
<CUCR151I>
- <DTL-SERVICES>
- <DTL-SERVICE>
  <KY-SPT>888888888</KY-SPT>
<CD-SPT-TYPE CISTableName="CIS99999" code="0100">Gas</CD-SPT-TYPE>
<CD-SPT-STAT>02</CD-SPT-STAT> 
  <TX-TAR-SCH-DESC>IL Residential Gas
Service</TX-TAR-SCH-DESC> 
  <DT-RATE-EFF />
<CD-SERV-DROP-LOC>9</CD-SERV-DROP-LOC> 
  <DTL-RIDERS /> 
- <DTL-USAGES>
-
<DTL-USAGE>
  <DT-LST-PRIM>200503</DT-LST-PRIM>
<DT-RDG-TO>2005-02-24</DT-RDG-TO> 
  <DT-RDG-FROM>2005-01-26</DT-RDG-FROM>
<AT-DB>28.66</AT-DB> 
  <QY-INDEX-1>1952</QY-INDEX-1>
<CD-RDG-SRCE>R</CD-RDG-SRCE> 
- <DTL-TOT-USAGES>
- <DTL-TOT-USAGE>
<QY-TOT-USAGE>14.5</QY-TOT-USAGE> 
  <CD-USAGE-TYPE CISTableName="CIS88888"
code="125">Total
Therm</CD-USAGE-TYPE> 
  </DTL-TOT-USAGE>
  </DTL-TOT-USAGES>
<DAYS-IN-PRD>29</DAYS-IN-PRD> 
    </DTL-USAGE>
  </DTL-USAGES>
</DTL-SERVICE>
- <DTL-SERVICE>
  <KY-SPT>999999999</KY-SPT> 
  <CD-SPT-TYPE
CISTableName="CIS77777"
code="0200">Electric</CD-SPT-TYPE>
<CD-SPT-STAT>02</CD-SPT-STAT> 
  <TX-TAR-SCH-DESC>Rate 1 Residential Electric
Service</TX-TAR-SCH-DESC>

  <DT-RATE-EFF />
<CD-SERV-DROP-LOC>9</CD-SERV-DROP-LOC> 
  <DTL-RIDERS /> 
- <DTL-USAGES>
-
<DTL-USAGE>
  <DT-LST-PRIM>200503</DT-LST-PRIM>
<DT-RDG-TO>2005-02-24</DT-RDG-TO> 
  <DT-RDG-FROM>2005-01-26</DT-RDG-FROM>
<AT-DB>62.4</AT-DB> 
  <QY-INDEX-1>51503</QY-INDEX-1>
<CD-RDG-SRCE>R</CD-RDG-SRCE> 
- <DTL-TOT-USAGES>
- <DTL-TOT-USAGE>
<QY-TOT-USAGE>1333</QY-TOT-USAGE> 
  <CD-USAGE-TYPE CISTableName="CIS66666"
code="010">Total
KWH</CD-USAGE-TYPE> 
  </DTL-TOT-USAGE>
  </DTL-TOT-USAGES>
<DAYS-IN-PRD>29</DAYS-IN-PRD> 
  </DTL-USAGE>
  </DTL-USAGES>
  </DTL-SERVICE>
</DTL-SERVICES>
  </CUCR151I>
************************************************************************
***********************************
Sample XSLT

<?xml version="1.0"
encoding="UTF-8" ?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version="1.0">
<xsl:key
name="usage-rows-by-dt-lst-prim" match="DTL-USAGES/DTL-USAGE"
use="DT-LST-PRIM" />		
<xsl:template match="/">	
 <table width="90%"
align="center" valign="top" cellpadding="2"
cellspacing="1">	
	<xsl:for-each
select="CUCR151I/DTL-SERVICES/DTL-SERVICE">

	<tr class="body">
	   <td
class="body" colspan="1">
	       <ul CLASS="clsItemsHide">
		<table
width="90%" align="left" valign="top" border="0">
		   <tr class="tableRowOdd"
valign="top">
			<td width="130" align="left" nowrap="nowrap"
colspan="4"><b>Premise(s)</b></td>
		    </tr>
		   <tr class="tableColHeader"
valign="top">
			<td width="130">
			   <table>
			     <tr>
			      <td>
<table>
				<tr class="tableColHeader">
				<td width="130" nowrap="nowrap"
align="center" valign="top">Bill Period</td>
				</tr>
				<tr
class="tableColHeader">
				    <td width="130" nowrap="nowrap"
align="center"
valign="bottom">(From  -  To)</td>
				       </tr>
				         </table>
</td>
				     </tr>
				       </table>
				   </td>				
				 <td width="130"
nowrap="nowrap"
align="center" valign="bottom">Days in Period</td>
				<td
width="130" nowrap="nowrap"
align="center" valign="bottom">Consumption</td>
<td width="130" nowrap="nowrap"
align="center" valign="bottom">Amount</td>
</tr>	
				<xsl:apply-templates
select="DTL-USAGES/DTL-USAGE[generate-id(.) =
generate-id(key('usage-rows-by-dt-lst-prim', DT-LST-PRIM)[1])]" >
</xsl:apply-templates>

				</table>	
				</ul>
		</td>
		</tr>
</xsl:for-each>
	</table>					
</xsl:template>

<xsl:template
match="DTL-USAGES/DTL-USAGE[position() mod 2 = 0]">
	<xsl:for-each
select="key('usage-rows-by-dt-lst-prim',
DT-LST-PRIM)">
	<tr
class="tableRowEven" valign="top">
	  	<td width="130">
		<table>
			<tr
class="tableRowEven" valign="top">
				<td width="40%" nowrap="nowrap"
align="left">
					<xsl:value-of
select="DT-RDG-FROM"/>
				</td>
				<td
width="20%">-</td>
				<td align="right" width="40%"
nowrap="nowrap">
<xsl:value-of
select="DT-RDG-TO"/>
				</td>
			</tr>
		</table>
		</td>
		<td
width="130" align="center">
		<xsl:value-of
select="format-number(DAYS-IN-PRD,'#00')"/></td>
		<td width="130">
			<table
width="130" align="left" valign="top"
border="0">
				<xsl:for-each
select="DTL-TOT-USAGES/DTL-TOT-USAGE">
				<tr class="tableRowEven"
valign="top">
				<td align="left">
					<xsl:value-of
select="CD-USAGE-TYPE"/>
				</td>
				<td align="right">
				<xsl:value-of
select="format-number(QY-TOT-USAGE,'#.0')"/>
				</td>

				</tr>
</xsl:for-each>
			</table>
		</td>
		<td width="130"
align="center"><xsl:value-of
select="format-number(AT-DB, '#.00')"/></td>
</tr>
	</xsl:for-each>
</xsl:template>				

<xsl:template
match="DTL-USAGES/DTL-USAGE[position() mod 2 = 1]">
	<xsl:for-each
select="key('usage-rows-by-dt-lst-prim',
DT-LST-PRIM)">
		<tr
class="tableRowOdd" valign="top">
		<td width="130">
		<table>
			<tr
class="tableRowOdd" valign="top">
				<td width="40%" nowrap="nowrap"
align="left">
					<xsl:value-of
select="DT-RDG-FROM"/>
				</td>
				<td
width="20%">-</td>
				<td align="right" width="40%"
nowrap="nowrap">
<xsl:value-of
select="DT-RDG-TO"/>
				</td>
			</tr>
		</table>
		</td>
		<td
width="130" align="center">
		<xsl:value-of
select="format-number(DAYS-IN-PRD,'#00')"/></td>
		<td width="130">
			<table
width="130" align="left" valign="top"
border="0">
				<xsl:for-each
select="DTL-TOT-USAGES/DTL-TOT-USAGE">
				<tr class="tableRowOdd"
valign="top">
				<td align="left">
					<xsl:value-of
select="CD-USAGE-TYPE"/>
				</td>
				<td align="right">
				<xsl:value-of
select="format-number(QY-TOT-USAGE,'#.0')"/>
				</td>

				</tr>
</xsl:for-each>
			</table>
		</td>
		<td width="130"
align="center"><xsl:value-of
select="format-number(AT-DB, '#.00')"/></td>
</tr>
	</xsl:for-each>
</xsl:template>						
</xsl:stylesheet>
*******************************
The information contained in this message may
be privileged and/or confidential and 
protected from disclosure. If the
reader of this message is not the intended recipient, 
or an employee or agent
responsible for delivering this message to the intended recipient, 
you are
hereby notified that any dissemination, distribution or copying of this
communication is strictly prohibited. Note that any views or opinions
presented in this 
message are solely those of the author and do not
necessarily represent those of Ameren. 
All emails are subject to monitoring
and archival. Finally, the recipient should check 
this message and any
attachments for the presence of viruses. Ameren accepts no liability 
for any
damage caused by any virus transmitted by this email. If you have received
this in 
error, please notify the sender immediately by replying to the
message and deleting the 
material from any computer. Ameren Corporation
*******************************

Current Thread