nesting xsl:for-each
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   S_Justin
Posted On:   Tuesday, April 29, 2003 02:42 PM

I need to nest xsl:for-each elements (or do something similar) to compare values to see if the inner element should be printed or not. It would look something like this:   <   <    <  <   <  <   <  <   < Now, in the I need to compare a value in the /loan/person element that I'm currently in to a value in every iteration through the /loan/money (for-each) so that an income element is generated where there is a match. Is this possible??? thanks. sjj    More>>

I need to nest xsl:for-each elements (or do something similar) to compare values to see if the inner element should be printed or not. It would look something like this:









  <

  < 

  <  <

  <  <

  <  <

  <









Now, in the I need to compare a value in the /loan/person element that I'm currently in to a value in every iteration through the /loan/money (for-each) so that an income element is generated where there is a match. Is this possible???

thanks.

sjj

   <<Less

Re: nesting xsl:for-each

Posted By:   Roseanne_Zhang  
Posted On:   Friday, May 2, 2003 07:04 AM

Here is an complete answer for you, include the XMLs XSLT and analysis.



Q. Should I use nested loop in this problem?

A: Interesting one, see the XML source and required result XML.


XML sourece




John Doe
111111111


Mary May
222222222


111111111
33400


111111111
1000


222222222
25000


333333333
40000



Required XML result











XSLT soureces for comparison



match="/people/income"
use="ssn" />















Important points here:


  • Loops here are nested. The outer loop is on , the inner loop is on the key

  • If inner loop is on , then it would be very inefficient.

  • The and key() function are playing the same role as index in database.

Re: nesting xsl:for-each

Posted By:   Stephen_McConnell  
Posted On:   Wednesday, April 30, 2003 05:12 AM

Yes it is possible. How you do this depends on the structure of your document.


What are the values you are comparing? What is the structure of your document?


Stephen McConnell

About | Sitemap | Contact