 |
 |
 |
Hi Katie,
> I am transforming XML to HTML. I am trying to sum up values. I need to
> display two totals. The first total is the Total Assets (amounts) for the
> primary borrower (Rank = 1). The second total is the Total Assets (amounts)
> for the secondary borrower (Rank = 2). What should my xsl look like in
> order to sum up the "Amount" values for the borrower with Rank = 1? (The
> same question would apply to summing the "Amount" values for borrower with
> Rank = 2).
>
> I want to display:
>
> Kelly Smith
> Total Assets: $1100
>
> John Smith
> Total Assets: $400
>
> A simplified version of my xml is:
>
> <Loan>
> <Borrower>
> <FirstName>Kelly</FirstName>
> <LastName>Smith</LastName>
> <Rank>1</Rank>
> <AssetSet>
> <Asset>
> <Amount>500</Amount>
> </Asset>
> <Asset>
> <Amount>600</Amount>
> </Asset>
> </AssetSet>
> </Borrower>
> <Borrower>
> <FirstName>John</FirstName>
> <LastName>Smith</LastName>
> <Rank>2</Rank>
> <AssetSet>
> <Asset>
> <Amount>100</Amount>
> </Asset>
> <Asset>
> <Amount>300</Amount>
> </Asset>
> </AssetSet>
> </Borrower>
> </Loan>
Well, there are more than one solution, depending on your context node.
Here is one:
<xsl:template match="Borrower">
<xsl:value-of select="FirstName" />
<xsl:text> </xsl:text>
<xsl:value-of select="LastName" />
<xsl:text>
Total Assets: $</xsl:text>
<xsl:value-of select="sum(AssetSet/Asset/Amount)" /> <!-- here -->
<xsl:text>
</xsl:text>
</xsl:template>
To choose a borrower use something like
<xsl:apply-template select="Borrower[Rank=1]" />
Hope that helps,
Oliver
/-------------------------------------------------------------------| ob|do Dipl.Inf. Oliver Becker |
| --+-- E-Mail: obecker@xxxxxxxxxxxxxxxxxxxxxxx |
| op|qo WWW: http://www.informatik.hu-berlin.de/~obecker |
\-------------------------------------------------------------------/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
 | 



|  |
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.
|  |
| |
 |
 |
 |