|
top
|
Subject: Printing non-existing value Author: prasad rama Date: 10 Feb 2009 07:58 PM
|
No, I can not use Saxon.
I have the data like this
{state abbr='TX'}
{product code="VA"}
{tier custom="240" ltv="0.01" min_amount="5000" rate="9.23" /}
{tier custom="240" ltv="10.01" min_amount="5000" rate="9.23" /}
{tier custom="240" ltv="20.01" min_amount="5000" rate="2.78" /}
{tier custom="240" ltv="0.01" min_amount="20000" rate="10.12" /}
{tier custom="240" ltv="10.01" min_amount="20000" rate="1.63" /}
{tier custom="240" ltv="20.01" min_amount="20000" rate="5.45" /}
{tier custom="240" ltv="30.01" min_amount="25000" rate="4.54" /}
{/product}
{product code=" "}
...............
...............
{/product}
{/state}
The output should look like this
Ltv(0) Ltv(10) Ltv(20)
Loan_amount(5000) 9.23 9.23 2.78
Loan_amount(20000) 10.12 1.63 5.45
Loan_amount(25000) None None 4.54
But with my code, I am getting the result like this
Ltv(0) Ltv(10) Ltv(20)
Loan_amount(5000) 9.23 9.23 2.78
Loan_amount(20000) 10.12 1.63 5.45
Loan_amount(25000) 4.54
Where the rate 4.54 should be in the 3rd column.
Here is my xsl..
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:key name="lien" match="/states/state/product/tier" use="concat(../../@abbr,../@code,@min_custom)"/>
<xsl:key name="ltv" match="/states/state/product/tier" use="concat(../../@abbr,../@code,@min_custom,@min_loan_amount,@min_ltv)"/>
<xsl:key name="loan" match="/states/state/product/tier" use="concat(../../@abbr,../@code,@min_custom,@min_loan_amount)"/>
<xsl:template match="/">
<html>
<body>
<table border="1" cellpadding="0" cellspacing="0">
<xsl:for-each select="/states/state[@abbr='TX']/product[@code='EMS']">
<xsl:for-each select="//tier[generate-id()=generate-id(key('lien',concat('TX','EMS','1'))[1])]">
<xsl:sort select="@min_custom" data-type="number" order="descending"/>
<xsl:variable name="custom" select="@min_custom"/>
<xsl:for-each select="../tier[generate-id()=generate-id(key('loan',concat('TX','EMS',$custom,@min_loan_amount))[1])]">
<xsl:sort select="@min_loan_amount" data-type="number" order="ascending"/>
<xsl:variable name="loan" select="@min_loan_amount"/>
<tr>
<td>
<xsl:value-of select="$loan"/>
</td>
<xsl:for-each select="../tier[generate-id()=generate-id(key('ltv',concat('TX','EMS',$custom,$loan,@min_ltv))[1])]">
<xsl:sort select="@min_ltv" data-type="number" order="ascending"/>
<td>
<xsl:value-of select="@rate"/>
</td>
</xsl:for-each>
</tr>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
In the above Xsl code, I am looping thru the nodes which has distinct custom, loan_amount and ltv values. For the 3rd loan_amount i.e, 25000 , we do not have the data for ltvs 0 and 10. So that the rate belongs to loan_amount 25000 is printing in the 1st position. I need to print that in the 3rd position.
To do that I need to loop thru loan_amount 25000 for 3 times, So that I can check for the condition and place "None" value if no data exists. Right now It loops thru only for once and if place any condition, it is not working.
Please suggest me how to solve this issue.
Thanks,
|
|
|
|