XSLT Translation

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
<pre class="prettyprint Hi All,
Trying to do transformation using for below sample xml.
However,not sure how to I repeate information ?
Each Deal more than 1 trade, hence I need to print deal,
Trade combination.
Below is my sample XML :
<?xml version="1.0" encoding="UTF-8"?>
<Root>
<dealId>
<id type="fiDealId" version=" 1004830B1</id>
</dealId>
<valuationGroups>
<valuationGroup>
<valuationType>STANDARD</valuationType>
<Trades>
<Trade>
<tradeId>
<id type="fiTmsTradeId" version="18 Trade1</id>
</tradeId>
</Trade>
</Trades>
</valuationGroup>
<valuationGroup>
<valuationType>STANDARD</valuationType>
<Trades>
<Trade>
<tradeId>
<id type="fiTmsTradeId" version="18 Trade2</id>
</tradeId>
</Trade>
</Trades>
</valuationGroup>
</valuationGroups>
</Root>
Below is XLS File :
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- Edited by me -->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform
<xsl:template match="/
<html>
<body>
Trades from control file: <xsl:value-of select="controlFile/header/dealCount" />
<table border="1
<tr bgcolor="#9acd32
<th>DealID</th>
<th>tradeId</th>
</tr>
<xsl:for-each select="controlFile/deals/deal
<tr>
<td><xsl:value-of select="valuationGroups/valuationGroup/Trades/Trade/book/id" /></td>
<xsl:for-each select="valuationGroups/valuationGroup
<td><xsl:value-of select="Trades/Trade/tradeId/id" /></td>
</xsl:for-each>
</tr>
</xsl:for-each>

</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
On executing above, I get below results.
DealId | TradeId
1004830B1| Trade1 | Trade2
Whereas I am expecting below results. Two lines inatead of single line.
DealId | TradeId
1004830B1| Trade1
1004830B1| Trade2 [/code]
<br/>
<br/>

View the full article
 
Back
Top