I have the following XML
<cost-detail>
<costcards>
<costcard>
<cost-code code="C-Copy">
<name>Reproduction Cost</name>
</cost-code>
<card-values>
<card-value type="billed">
<amount>0.05</amount>
</card-value>
</card-values>
</costcard>
<costcard>
<cost-code code="C-Copy">
<name>Reproduction Cost</name>
</cost-code>
<card-values>
<card-value type="billed">
<amount>0.05</amount>
</card-value>
</card-values>
</costcard>
<costcard>
<cost-code code="D-Court">
<name>Court Filing Fees</name>
</cost-code>
<card-values>
<card-value type="billed">
<amount>1027.50</amount>
</card-value>
</card-values>
</costcard>
<costcard>
<cost-code code="D-Court">
<name>Court Filing Fees</name>
</cost-code>
<card-values>
<card-value type="billed">
<amount>27.50</amount>
</card-value>
</card-values>
</costcard>
</costcards>
</cost-detail>
I have the following XSLT sheet:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:aml="http://schemas.microsoft.com/aml/2001/core"
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:tlr="http://www.elite.com/functions"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:sl="http://schemas.microsoft.com/schemaLibrary/2003/core"
xmlns:st1="urn:schemas-microsoft-com:office:smarttags"
xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml"
xmlns:w10="urn:schemas-microsoft-com:office:word"
xmlns:wsp="http://schemas.microsoft.com/office/word/2003/wordml/sp2"
xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:template name="Prof_DisbSummary">
<xsl:variable name="TW" select="1440"/>
<w:tbl>
<xsl:variable name="Col1" select="2.50 * $TW"/>
<xsl:variable name="Col2" select="1 * $TW"/>
<w:tblPr>
<w:jc w:val="center"/>
<w:tblBorders>
<w:top w:val="single" w:sz="1"/>
<w:left w:val="single" w:sz="1"/>
<w:bottom w:val="single" w:sz="1"/>
<w:right w:val="single" w:sz="1"/>
</w:tblBorders>
<w:tblW w:w="0" w:type="dxa"/>
<w:tblLayout w:type="Fixed"/>
<w:tblCellMar>
<w:left w:w="0" w:type="dxa"/>
<w:right w:w="0" w:type="dxa"/>
</w:tblCellMar>
</w:tblPr>
<w:tblGrid>
<w:gridCol w:w="{$Col1}"/>
<w:gridCol w:w="{$Col2}"/>
<w:gridCol w:w="{$Col3}"/>
</w:tblGrid>
<w:tr>
<!-- Cost Code Header -->
<w:tc>
<tcPr>
<w:tcW w:w="{$Col1}" w:type="dxa"/>
<w:shd w:val="solid" w:fill="auto" w:color="000080"/>
</tcPr>
<w:p>
<w:r>
<w:rPr>
<w:b/>
<w:color w:val="FFFFFF"/>
</w:rPr>
<w:t> Cost Code</w:t>
</w:r>
</w:p>
</w:tc>
<!-- Cost Code Header -->
<w:tc>
<tcPr>
<w:tcW w:w="{$Col2}" w:type="dxa"/>
<w:shd w:val="solid" w:fill="auto" w:color="000080"/>
</tcPr>
<w:p>
<w:pPr>
<w:jc w:val="right"/>
</w:pPr>
<w:r>
<w:rPr>
<w:b/>
<w:color w:val="FFFFFF"/>
</w:rPr>
<w:t>Amount </w:t>
</w:r>
</w:p>
</w:tc>
</w:tr>
<xsl:for-each select="//superbill/invoice/matters/matter/cost-detail/costcards/costcard">
<w:tr>
<!-- Cost Code Data -->
<w:tc>
<tcPr>
<w:tcW w:w="{$Col1}" w:type="dxa"/>
</tcPr>
<w:p>
<w:r>
<w:t> <xsl:value-of select="summarize-to/code"/> - <xsl:value-of select="summarize-to/name"/></w:t>
</w:r>
</w:p>
</w:tc>
<!-- Amount Data -->
<w:tc>
<tcPr>
<w:tcW w:w="{$Col2}" w:type="dxa"/>
</tcPr>
<w:p>
<w:pPr>
<w:jc w:val="right"/>
</w:pPr>
<w:r>
<w:t><xsl:value-of select="card-values/card-value[@type='billed']/amount"/> </w:t>
</w:r>
</w:p>
</w:tc>
</w:tr>
</xsl:for-each>
<!-- Totals Rows -->
<w:tr>
<!-- Cost Code Total -->
<w:tc>
<tcPr>
<w:tcW w:w="{$Col1}" w:type="dxa"/>
<w:tcBorders>
<w:top w:val="single" w:sz="1"/>
</w:tcBorders>
</tcPr>
<w:p>
<w:r>
<w:rPr>
<w:b/>
</w:rPr>
<w:t> Total Disbursements:</w:t>
</w:r>
</w:p>
</w:tc>
<!-- Amount Date -->
<w:tc>
<tcPr>
<w:tcW w:w="{$Col2}" w:type="dxa"/>
<w:tcBorders>
<w:top w:val="single" w:sz="1"/>
</w:tcBorders>
</tcPr>
<w:p>
<w:pPr>
<w:jc w:val="right"/>
</w:pPr>
<w:r>
<w:rPr>
<w:b/>
</w:rPr>
<w:t><xsl:value-of select="//superbill/invoice/matters/matter/billing-summary/totals-summary/total[@type='disbursements']"/> </w:t>
</w:r>
</w:p>
</w:tc>
</w:tr>
</w:tbl>
</xsl:template>
</xsl:stylesheet>
Which displays...
What I want to be able to do is, show each DISTINCT "Cost-Code" (C-Copy & D-Court) with the SUM of the amounts on each line, not each single cost code and their amounts. To look like:
Is this at all possible?
Thank you in advance.