Tricky XSLT for-each conditional problem.

Discussion in 'XML' started by crabsdf, Apr 29, 2008.

  1. crabsdf

    crabsdf

    Joined:
    Apr 29, 2008
    Messages:
    1
    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?
     
    crabsdf, Apr 29, 2008
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alec S.
    Replies:
    10
    Views:
    10,308
    Alec S.
    Apr 16, 2005
  2. Tjerk Wolterink

    xsl:for-each for each 3 elements problem

    Tjerk Wolterink, Nov 3, 2004, in forum: XML
    Replies:
    3
    Views:
    456
    Tjerk Wolterink
    Nov 3, 2004
  3. R
    Replies:
    2
    Views:
    3,342
    Ben LamHang
    Mar 18, 2005
  4. nirkheys@gmail.com

    a tricky if else(maybe not tricky but impossible)

    nirkheys@gmail.com, Apr 25, 2006, in forum: C Programming
    Replies:
    9
    Views:
    561
    CBFalconer
    Apr 25, 2006
  5. Stryder
    Replies:
    2
    Views:
    2,081
    Stryder
    Apr 2, 2009
Loading...

Share This Page