Tricky XSLT for-each conditional problem.

Joined
Apr 29, 2008
Messages
1
Reaction score
0
Here's a snippet of my xml data:
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]) &gt; 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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top