XML : Eliminating duplicate element if the elements are on the same level in XSLT

I'm looking to display the ContributionFunds elements in the first LoanDetails element; ContributionFunds and LoanDetails are repeatable element so for displaying them i've made two templates;

Question: Is there a way to output the information just in the desired path ? It doesn't matter if i will use XSLT 1.0 or 2.0.

Sample:

  <root>   <ContributionFunds Amount="546548" Type="NetProceedsFromSaleOfProperty"/>   <ContributionFunds Amount="10000000" Type="Savings"/>   <LoanDetails ProductName="Variable Home Loan IO" ProductCode="VHLIO"/>   <LoanDetails ProductName="Variable Home Loan IO" ProductCode="VHLIO"/>  </root>    

The output obtained if applying the template ContributionFunds in LoanDetails template

      <root>        <LoanDetails ProductName="Variable Home Loan IO" ProductCode="VHLIO2">          <ContributionFunds Amount="546548" Type="NetProceedsFromSaleOfProperty"/>          <ContributionFunds Amount="10000000" Type="Savings"/>        </LoanDetails>        <LoanDetails ProductName="Variable Home Loan IO" ProductCode="VHLIO2">          <ContributionFunds Amount="546548" Type="NetProceedsFromSaleOfProperty"/>          <ContributionFunds Amount="10000000" Type="Savings"/>        </LoanDetails>      </root>    

The desired output

  <root>     <LoanDetails ProductName="Variable Home Loan IO" ProductCode="VHLIO2">      <ContributionFunds Amount="546548" Type="NetProceedsFromSaleOfProperty"/>      <ContributionFunds Amount="10000000" Type="Savings"/>    </LoanDetails>    <LoanDetails ProductName="Variable Home Loan IO" ProductCode="VHLIO"/>  </root>    

No comments:

Post a Comment