Here's a snippet of my xml data:
Basically I want up to three (in this case only) iterations of a loop, one for each node "tsmf_fund" in //StaticData. I say up to three because I only want to do the loop iteration if the fund_id is actually used somewhere in //Transactions. In this example I don't want the iteration of the loop for fund_id = 3 because it is not used.
This is what i've tried so far, all not returning any results.
More specifically, the condition is: there exists a node "Transaction" in //Transactions/ which contains a node "FundTransaction" which has /tsmf_fund/fund_id equal to the fund_id in the iteration of the //StaticData loop.
Anyone know what i'm doing wrong?
Code:
<Transactions>
<Transaction>
<FundTransaction>
<tsmf_fund><fund_id>1</fund_id></tsmf_fund>
<!--data I need->
</FundTransaction>
<FundTransaction>
<tsmf_fund><fund_id>2</fund_id></tsmf_fund>
<!--data I need-->
</FundTransaction>
</Transaction>
<Transaction>
<FundTransaction>
<tsmf_fund><fund_id>1</fund_id></tsmf_fund>
<!--data I need-->
</FundTransaction>
</Transaction>
</Transactions>
<StaticData>
<tsmf_fund>
<fund_id>1</fund_id>
</tsmf_fund>
<tsmf_fund>
<fund_id>2</fund_id>
</tsmf_fund>
<tsmf_fund>
<fund_id>3</fund_id>
</tsmf_fund>
</StaticData>
Basically I want up to three (in this case only) iterations of a loop, one for each node "tsmf_fund" in //StaticData. I say up to three because I only want to do the loop iteration if the fund_id is actually used somewhere in //Transactions. In this example I don't want the iteration of the loop for fund_id = 3 because it is not used.
This is what i've tried so far, all not returning any results.
Code:
<xsl:for-each select="//StaticData/tsmf_fund[count(//Transaction/FundTransaction[tsmf_fund/fund_id = current()/fund_id]) > 0]">
<xsl:for-each select="//StaticData/tsmf_fund[//Transaction/FundTransaction[tsmf_fund/fund_id = current()/fund_id]]">
<xsl:for-each select="//StaticData/tsmf_fund[//Transaction/FundTransaction/tsmf_fund/fund_id = current()/fund_id]">
<xsl:for-each select="//StaticData/tsmf_fund[//FundTransaction/tsmf_fund/fund_id = current()/fund_id]">
<xsl:for-each select="//StaticData/tsmf_fund[//FundTransaction/[tsmf_fund/fund_id = current()/fund_id]]">
More specifically, the condition is: there exists a node "Transaction" in //Transactions/ which contains a node "FundTransaction" which has /tsmf_fund/fund_id equal to the fund_id in the iteration of the //StaticData loop.
Anyone know what i'm doing wrong?