xsl-list
[Top] [All Lists]

Totals for conditional sums ?maybe?

2005-12-02 18:31:18

Well let me start by saying this is a mess mainly because I have no idea of 
what I'm doing.  After researching this problem I've realized that my style 
sheet could definitely be formatted better.  However I'm just trying to update 
a baseline version so I didn't want to rewrite the whole thing (little did I 
know that I would almost anyway).

I apologize for including so much entire style sheet below, which I know is bad 
form having combed the lists for an answer and seeing all the tiny examples, 
but most of the time I can't seem to comprehend the answers when only a snippet 
of code is used.

What I am trying to do is total the ORDD_TLNA for the base years when 
//AwardFullData/AwardItemizedLine[count(./periodLinePeriodNumber)<1] and 
then later total ORDD_TLNA for the option years when 
//AwardFullData/AwardItemizedLine[count(./periodLinePeriodNumber)>0]">

I have tried so many iterations I have forgotten them all but I think the 
closest I have gotten is this:

<xsl:variable name="TEST" 
select="//AwardFullData/AwardItemizedLine[count(./periodLinePeriodNumber)&lt;1]"/>
<xsl:variable name="ADDME" 
select="//AwardFullData/AwardItemizedLine/transactionAmount"/>
...

<xsl:value-of select="sum($ADDME[$TEST])"/>
The result was NaN (also at one point I checked for only numerical values 
before sum and received 0)


Not even sure if the above was correct I tried to strip the formatting of the 
data which includes $ and , (I have no control over the data source).
<xsl:value-of select="sum((translate($ADDME,'$,',''))[$TEST])"/>


THANKS!! Any help would be greatly appreciated I've been looking at the same 
problem for 2 days.



Style sheet
..................................                    
                     
                     <!--Base Year-->
                           <xsl:for-each 
select="//AwardFullData/AwardItemizedLine[count(./periodLinePeriodNumber)&lt;1]">
                           <xsl:variable name="LNUM" select="./lineNumber"/>
                           <xsl:variable name="SLNUM" select="./subLineNumber"/>
                           <xsl:variable name="CMDT_NM" 
select="./commodityName"/>
                           <xsl:variable name="QTY_ORIG" 
select="./originalQuantity"/>
                           <xsl:variable name="QTY_INCR" 
select="./incrementQuantity"/>
                           <xsl:variable name="QTY_TOTAL" select="./quantity"/>
                           <xsl:variable name="UNIT_OF_MESR" 
select="./unitOfMeasure"/>
                           <xsl:variable name="UNPR_TA_CH" 
select="./precreditUnitPriceTransactionAmount"/>
                           <xsl:variable name="UNPR_INCT_TA_CH" 
select="./precreditUnitPriceIncrementTransactionAmount"/>
                           <xsl:variable name="UNPR_ORIG_TA_CH" 
select="./originalPrecreditUnitPriceTransactionAmount"/>
                           <xsl:variable name="ORDD_TLNA" 
select="./transactionAmount"/>
                           <xsl:variable name="ORDD_INCT_TLNA" 
select="./incrementTransactionAmount"/>
                           <xsl:variable name="ORDD_ORIG_TLNA" 
select="./originalTransactionAmount"/>                      
                           <xsl:variable name="DLVR_DT_CH" 
select="./deliveryDate"/>
                           <xsl:variable name="PERD_PERF_STDT_CH" 
select="./periodPerformanceStartDate"/>
                           <xsl:variable name="PERD_PERF_ENDT_CH" 
select="./periodPerformanceEndDate"/>
                           <xsl:variable name="DSCR" select="./description"/>
                           <xsl:variable name="EXT_DSCR" 
select="./extendedDescription"/>
                           <xsl:variable name="REF_DOC_TYPE" 
select="./referenceDocumentType"/>
                           <xsl:variable name="REF_DOC_NUM" 
select="./referenceDocumentNumber"/>
                           <xsl:variable name="REF_LINE_NUM" 
select="./referenceLineNumber"/>
                           <xsl:variable name="CONTRACT_NUM" 
select="./contractNumber"/>
                           <xsl:variable name="LINE_STATUS" 
select="./objectChangeStatus"/>
                           <xsl:variable name="CLIN" 
select="./contractLineItemNumber"/>
                           <xsl:variable name="PERD_LINE_PERD_NUM" 
select="./periodLinePeriodNumber"/>
                                                      
                           <fo:table line-height="0.3in" 
border-collapse="collapse" table-layout="fixed">
                                  <?ShowGrid true?>
                                  <?ShowHeaderGrid true?>
                                  <fo:table-column column-number="1" 
column-width="47px"/>
                                  <fo:table-column column-number="2" 
column-width="180px"/>
                                  <fo:table-column column-number="3" 
column-width="80px"/>
                                  <fo:table-column column-number="4" 
column-width="51px"/>
                                  <fo:table-column column-number="5" 
column-width="88px"/>
                                  <fo:table-column column-number="6" 
column-width="93px"/>
                                  <fo:table-header text-align="center">
                                         <fo:table-row>
                                                <fo:table-cell 
border-style="solid">
                                                       <fo:block 
text-align="center" font-family="Helvetica" font-weight="bold" 
font-size="8pt">Number</fo:block>
                                                </fo:table-cell>
                                                <fo:table-cell 
border-style="solid">
                                                       <fo:block 
text-align="center" font-weight="bold">Commodity Name or Service</fo:block>
                                                </fo:table-cell>
                                                <fo:table-cell 
border-style="solid">
                                                       <fo:block 
text-align="center" font-weight="bold">Quantity</fo:block>
                                                </fo:table-cell>
                                                <fo:table-cell 
border-style="solid">
                                                       <fo:block 
text-align="center" font-weight="bold">Unit of Issue</fo:block>
                                                </fo:table-cell>
                                                <fo:table-cell 
border-style="solid">
                                                       <fo:block 
text-align="center" font-weight="bold">Unit Price</fo:block>
                                                </fo:table-cell>
                                                <fo:table-cell 
border-style="solid">
                                                       <fo:block 
text-align="center" font-weight="bold">Total Cost ( Inc. disc and 
tax)</fo:block>
                                                </fo:table-cell>
                                         </fo:table-row>
                                  </fo:table-header>
                                  <fo:table-body>
...................
                                  <xsl:if test="$PRINT_CHANGE_AMOUNTS">
                                         <fo:block>Original Total:  
<xsl:value-of select="./originalPrecreditLineTransactionAmount"/>
                                         </fo:block>
                                         <fo:block>Change Total:  <xsl:value-of 
select="$ORDD_INCT_TLNA"/>
                                         </fo:block>
                                  </xsl:if>
                                  <fo:block>Total:  <xsl:value-of 
select="$ORDD_TLNA"/>
                                  </fo:block>
                                  <fo:block white-space-collapse="false" 
font-family="Helvetica" font-size="9pt">
                                         <xsl:value-of select="' '"/>
                                  </fo:block>
                           </xsl:for-each>
                     </xsl:for-each>
                     
                     
                     <!--BASE YEAR TOTAL-->
                           
                     <fo:block white-space-collapse="false" 
border-bottom-style="solid" font-size="9pt">
                     
                     </fo:block>   
                     <fo:block font-weight="bold" font-size="9pt">
                           <fo:inline>BASE YEAR TOTAL:  </fo:inline>
                     </fo:block>
                     <fo:block white-space-collapse="false" 
border-bottom-style="solid" font-size="9pt">
                           <xsl:value-of select="' '"/>
                     </fo:block>   
                     
                                              
                     
                     <!--FOOTER--> 
                     
                     <fo:block font-weight="bold" font-size="9pt">
                           <xsl:value-of select="$FOOTER"/>
                     </fo:block>
                     <fo:block white-space-collapse="false" 
border-bottom-style="solid" font-size="9pt">
                           <xsl:value-of select="' '"/>
                     </fo:block>
              </fo:flow>
       </fo:page-sequence>
</fo:root>


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--