Quantcast
Channel: XML, System.Xml, MSXML and XmlLite forum
Viewing all articles
Browse latest Browse all 935

Sum of similar tag elements in XSLT

$
0
0

I'm  already have write a XSLT for xml mapping for slimier tag, according to that out put coming with same tag repeating and few tagging, i want to summarize that similar tag including values sum.Can you please help on this.

Current XSLT Mapping 

<InvoiceType><xsl:value-of select="//cw:TransactionInfo/cw:ShipmentCollection/cw:Shipment/cw:SubShipmentCollection/cw:SubShipment/cw:JobCosting/cw:ChargeLineCollection/cw:ChargeLine/cw:SellInvoiceType"/></InvoiceType>


<xsl:for-each select = "//cw:TransactionInfo/cw:PostingJournalCollection"> 

                 <xsl:if test = "cw:PostingJournal/cw:ChargeCode/cw:Code[text()='DO']"> 

             <DOC> <xsl:value-of select="//cw:PostingJournalCollection/cw:PostingJournal/cw:ChargeCode/cw:Code[text()='DO']/ancestor::cw:PostingJournal/cw:ChargeTotalAmount"/> </DOC>

                  </xsl:if> 

<xsl:if test = "cw:PostingJournal/cw:ChargeCode/cw:Code[text()='DDOCU']"> 

             <DOC> <xsl:value-of select="//cw:PostingJournalCollection/cw:PostingJournal/cw:ChargeCode/cw:Code[text()='DDOCU']/ancestor::cw:PostingJournal/cw:ChargeTotalAmount"/> </DOC>

                  </xsl:if>

                 <xsl:if test = "cw:PostingJournal/cw:ChargeCode/cw:Code[text()='IOUDDOCUM']"> 

             <DOC> <xsl:value-of select="//cw:PostingJournalCollection/cw:PostingJournal/cw:ChargeCode/cw:Code[text()='IOUDDOCUM']/ancestor::cw:PostingJournal/cw:ChargeTotalAmount"/> </DOC>

                  </xsl:if>

                <xsl:if test = "cw:PostingJournal/cw:ChargeCode/cw:Code[text()='CONGESC']"> 

            <FREIGHT> <xsl:value-of select="//cw:PostingJournalCollection/cw:PostingJournal/cw:ChargeCode/cw:Code[text()='CONGESC']/ancestor::cw:PostingJournal/cw:ChargeTotalAmount"/> </FREIGHT>

                  </xsl:if>

                 <xsl:if test = "cw:PostingJournal/cw:ChargeCode/cw:Code[text()='FRT']"> 

            <FREIGHT> <xsl:value-of select="//cw:PostingJournalCollection/cw:PostingJournal/cw:ChargeCode/cw:Code[text()='FRT']/ancestor::cw:PostingJournal/cw:ChargeTotalAmount"/> </FREIGHT>

                  </xsl:if>

                 <xsl:if test = "cw:PostingJournal/cw:ChargeCode/cw:Code[text()='GRI']"> 

            <FREIGHT> <xsl:value-of select="//cw:PostingJournalCollection/cw:PostingJournal/cw:ChargeCode/cw:Code[text()='GRI']/ancestor::cw:PostingJournal/cw:ChargeTotalAmount"/> </FREIGHT>

                  </xsl:if>

Current Out put

<InvoiceNo>AR INV EFL-CM1-00026395</InvoiceNo>
<InvoiceType>
</InvoiceType>
<DOC>1000.0000</DOC>
<DOC>1000.0000</DOC>
<DOC>1000.0000</DOC>
<FREIGHT>1000.0000</FREIGHT>
<FREIGHT>1000.0000</FREIGHT>
<FREIGHT>1000.0000</FREIGHT>
<FREIGHT>1000.0000</FREIGHT>
<EXW>1000.0000</EXW>
<EXW>1000.0000</EXW>
<EXW>1000.0000</EXW>

Expected Result'

<InvoiceNo>AR INV EFL-CM1-00026395</InvoiceNo>
<InvoiceType>
</InvoiceType>
<DOC>3000.0000</DOC>
<FREIGHT>4000.0000</FREIGHT>
<EXW>3000.0000</EXW>

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             

Viewing all articles
Browse latest Browse all 935

Trending Articles