Manipulating variables in XSL
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Jijo_Thomas
Posted On:   Monday, June 28, 2004 04:01 AM

I have a collection of objects say, Friends. I need to write an XSL that fetches me only the first friend who satisfies a condition. ie, I need only the first friend (from my list) who has scored an A+ in History test. Example : Here is a list of my friends with their grades in History test.               Andy          B                    Michael          B+                    Susan          A+                    George          A+         More>>


I have a collection of objects say, Friends. I need to write an XSL that fetches me only the first friend who satisfies a condition. ie, I need only the first friend (from my list) who has scored an A+ in History test.




Example :

Here is a list of my friends with their grades in History test.





    

         Andy

         B

    


    

         Michael

         B+

    


    

         Susan

         A+

    


    

         George

         A+

    


    

         Jack

         B

    


    

         Jeniffer

         B

    






I need to write an XSL that would chose the first friend in the list who has scored an A+ in History test.



Java Equivalent
I would done it in java as follows




boolean friendFound = false;


....

while (myFriendsItr.hasNext() && ! friendFound) {

     friend = (Friend)  myFriendsItr.next();

     if (friend.getGradeHistory().equals("A+")) {

        friendFound = true;

    }

}



....




Problem in using this logic with XSL
Since values of variables once set in XSL can not be updated, i can not use this logic in XSL. Is there any way by which i can solve my problem using XSl?

   <<Less

Re: Manipulating variables in XSL

Posted By:   Ivo_Limmen  
Posted On:   Monday, June 28, 2004 04:12 AM

I think this would work as you described:



This will return the first 'Friend' node where the gradeHistory is 'A+'.
About | Sitemap | Contact