Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

select node where attribute = ???

Status
Not open for further replies.

keenanbr

Programmer
Oct 3, 2001
469
IE
I have an XML File:


<year final_ind="No" year_no="24">
<sum_contributions>73137.60</sum_contributions>
<sum_growth>127048.51</sum_growth>
<sum_gross_fund_value>202660.53</sum_gross_fund_value>
<sum_net_fund_value>181598.03</sum_net_fund_value>
<pv_sum_gross_fund_value>79062.23</pv_sum_gross_fund_value>
<pv_sum_net_fund_value>70845.29</pv_sum_net_fund_value>
<sum_expenses>21062.50</sum_expenses>
<sum_protection_costs>0.00</sum_protection_costs>
</year>
<year final_ind="Yes" year_no="25">
<sum_contributions>74153.40</sum_contributions>
<sum_growth>132101.67</sum_growth>
<sum_gross_fund_value>208729.49</sum_gross_fund_value>
<sum_net_fund_value>186991.42</sum_net_fund_value>
<pv_sum_gross_fund_value>80248.51</pv_sum_gross_fund_value>
<pv_sum_net_fund_value>71891.06</pv_sum_net_fund_value>
<sum_expenses>21738.07</sum_expenses>
<sum_protection_costs>0.00</sum_protection_costs>
</year>

I want to find year_no (25) where final_ind = 'Yes'
and then process year_no - 1 (24)

Below is a test XSLT which correctly select the final_ind = 'Yes' Node but I don't know how to continue..


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl=" <xsl:eek:utput method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/message">
<FinalYear>
<xsl:variable name="FinalYear" select="m-content/application/document_out/yearly_values[@growth_rate_type='Standard']/year[@final_ind='Yes'][@year_no]">
</xsl:variable>
<xsl:variable name="AnnYear" select="$FinalYear">
</xsl:variable>

</FinalYear>
</xsl:template>
</xsl:stylesheet>
 
It's usually a good idea to post how you figured it out
 
Fair enough, fawkes. Here's the solution


<xsl:variable name="YearBeforeMaturity">
<xsl:call-template name="getYearBeforeMaturity">
</xsl:call-template>
</xsl:variable>

<xsl:template name="getYearBeforeMaturity">
<xsl:variable name="FinalYear" select="m-content/application/document_out/yearly_values/year[@final_ind='Yes']/@year_no">
</xsl:variable>
<xsl:variable name="YearBeforeMaturity" select="$FinalYear -1">
</xsl:variable>
<xsl:value-of select="$YearBeforeMaturity">
</xsl:value-of>
</xsl:template>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top