Looping an array

I'm trying to loop an array inside another loop and am running into an issue.  The problem is that the inside loop works but it is looping the outisde loop x number of times
This is where the code is so far.  Any ideas what i'm doing wrong?
<cfset myList = ValueList(AccountProducts.PID)>
<cfset myList = listtoarray(myList)>
<CFLOOP QUERY="GetProductList">
    <CFLOOP index="VPU" from="1" to="#ArrayLen(myList)#">
        <CFIF PID EQ #myList[VPU]#>
            <CFINPUT NAME="SKUName" TYPE="checkbox" VALUE="#PID#" CHECKED="Yes" />#SKUName# <br />
        <CFELSE>
            <CFINPUT NAME="SKUName" TYPE="checkbox" VALUE="#PID#" CHECKED="NO" />#SKUName# <br />
        </CFIF>     
    </CFLOOP>       
</CFLOOP>
so an example of what it is doing now is
Product 1
Product 1
Product 1
Product 2
Product 2
Product 2
Product 3
Product 3
Product 3

Coder76 wrote:
I'm trying to loop an array inside another loop and am running into an issue.  The problem is that the inside loop works but it is looping the outisde loop x number of times
Well you are getting exactly what you have coded.
Your output is inside the inner loop, so it is going to output something every time.  The fix that is most similar to what you have already coded would be to set a flag inside the inner loop and do your output in the outer loop.
<CFLOOP QUERY="GetProductList">
    <cfset checked = "NO">
    <CFLOOP index="VPU" from="1" to="#ArrayLen(myList)#">
        <CFIF PID EQ myList[VPU]>
            <cfset checked = "YES">
        </CFIF>     
    </CFLOOP>  
    <CFINPUT NAME="SKUName" TYPE="checkbox" VALUE="#PID#" CHECKED="#checked#" />#SKUName# <br />
</CFLOOP>
But there are other ways to do this that would involve less lines of code using some of the list functions.
http://livedocs.adobe.com/coldfusion/8/htmldocs/functions-pt0_13.html
I think this would produce the same output.
<cfset myList = ValueList(AccountProducts.PID)>
<CFLOOP QUERY="GetProductList">
    <CFINPUT NAME="SKUName" TYPE="checkbox" VALUE="#PID#" CHECKED="#yesNoFormat(listFind(myList,PID))#" />#SKUName# <br />
</CFLOOP>

Similar Messages

  • Loops in arrays or structures

    Loops in arrays or structures
    I was given a project on html reports and
    They have advised me to use Loops in arrays or structures
    At this point I am a novice at this html reporting system. I
    would like to know how I can use loops in arrays or structures.
    How is it beneficial are
    1. Structures
    2. Arrays
    3. loops in for both
    for my reports.
    Countless thanks in advance

    Structures are great if you understand them, they are
    basically just arrays organized by keywords rather than index
    numbers.
    Arrays are very nice, as you can just run through loops to
    access each element, as they are all indexed by numbers 0-x.
    loops are great to navigate through both. All you have to do
    is set an loop to run through x amount of iterations of the array
    or structure (where x is the length of the array, or number of
    elements in the structure). Loops are great due to the small amount
    of code they require.

  • Loops and Arrays help

    Hi,
    I'm a freshman in college and new to java. I am completely lost and really need help with a current assignment. Here are the instructions given by my teacher...
    Building on provided code:
    Loops and Arrays
    Tracking Sales
    Files Main.java and Sales.java contain a Java application that prompts for and reads in the sales for each of 5 salespeople in a company. Files Main.java and Sales.java can be found here http://www.ecst.csuchico.edu/~amk/foo/csci111/labs/lab6N/Main.java
    and here http://www.ecst.csuchico.edu/~amk/foo/csci111/labs/lab6N/Sales.java It then prints out the id and amount of sales for each salesperson and the total sales. Study the code, then compile and run the program to see how it works. Now modify the program as follows:
    1. (1 pts) Compute and print the average sale. (You can compute this directly from the total; no new loop is necessary.)
    2. (2 pts) Find and print the maximum sale. Print both the id of the salesperson with the max sale and the amount of the sale, e.g., "Salesperson 3 had the highest sale with $4500." Note that you don't necessarily need another loop for this; you can get it in the same loop where the values are read and the sum is computed.
    3. (2 pts) Do the same for the minimum sale.
    4. (6 pts) After the list, sum, average, max and min have been printed, ask the user to enter a value. Then print the id of each salesperson who exceeded that amount, and the amount of their sales. Also print the total number of salespeople whose sales exceeded the value entered.
    5. (2 pts) The salespeople are objecting to having an id of 0-no one wants that designation. Modify your program so that the ids run from 1-5 instead of 0-4. Do not modify the array-just make the information for salesperson 1 reside in array location 0, and so on.
    6. (8 pts) Instead of always reading in 5 sales amounts, allow the user to provide the number of sales people and then create an array that is just the right size. The program can then proceed as before. You should do this two ways:
    1. at the beginning ask the user (via a prompt) for the number of sales people and then create the new array
    2. you should also allow the user to input this as a program argument (which indicates a new Constructor and hence changes to both Main and Sales). You may want to see some notes.
    7. (4 pts) Create javadocs and an object model for the lab
    You should organize your code so that it is easily readable and provides appropriate methods for appropriate tasks. Generally, variables should have local (method) scope if not needed by multiple methods. If many methods need a variable, it should be an Instance Variable so you do not have to pass it around to methods.
    You must create the working application and a web page to provide the applications information (i.e., a page with links to the source code, the javadoc and an object model) to get full credit. You can use the example.html's from the last two labs to help you remember how to do this.
    I'm not asking for someone to do this assignment for me...I'm just hoping there is someone out there patient and kind enough to maybe give me a step by step of what to do or how to get started, because I am completely lost from the beginning of #1 in the instructions.
    Any help would be much appreciated! Thank you!
    Message was edited by:
    Scott_010
    Message was edited by:
    Scott_010

    First ask the person who gave this asignment as to why do you require two classes for this , you can have only the Sales.java class with main method in it . Anyways.
    Let Main.java have a main method which instanciates a public class Sales and calls a method named say readVal() in Sales class.
    In the readVal method of sales class define two arrays i.e ids and sales. Start prompting the user for inputting the id and sales and with user inputting values keep storing it in the respective arrays .. Limit this reading to just 5 i.e only 5 salesPerson.
    Once both the arrays are populated, call another method of Sales class which will be used for all computations and output passing both the arrays.
    In this new method say Compute() , read values from array and keep calculating total,average and whatever you want by adding steps in just this loop. You can do this in readval method too after reading the values but lets keep the calculation part seperate from input.
    You must create the working application and a web page to provide the applications information (i.e., a page with links to the source code, the javadoc and an object model) to get full credit. You can use the example.html's from the last two labs to help you remember how to do this. I think this is ur personal stuff , but if you want to use web page , you probably will require to use servlet to read values from the html form passed to the server.

  • Dynamic List - Error processing insertText tag: 'loop' parameter arrays must be...

    Hi, I'm using Dreamweaver CS3 and ADDT (PHP/MySQL).
    I have many forms that I created with "Create Dynamic List Wizard", and All it's working fine until now, suddendly when I enter an any form, click Application / Server Behaviors, I saw a red symbol "!" next to Dynamic List Layout, I clicked it in order to make any changes, and then when I tried to save I got the following error message:
    "Error processing insertText tag: 'loop' parameter arrays must be the same length. The 'loop' parameter 'tableCSSWidth' does not have the same length as the previous 'loop' parameter(s)."
    This is happening with others form in my application. I can made some changes through "code", but others no...
    I would like to know what its' happening with then "dynamic List" server behavior?
    I appreciate your help. Thanks!
    Ernesto

    Hello Ernesto,
    Please follow these exact steps:
    - go to this location on your disk (enable view of hidden files):
    - "c:\Documents and Settings\XP_user\Application Data\Adobe\Dreamweaver 9\Configuration"
    ( if you are on Windows OS)
    or:
    - "Macintosh HD:Users:MAC_User:Library:Application Support:Adobe:Dreamweaver 9:Configuration"
    ( if you are on MAC OSX)
    - rename the "Configuration" folder to "Configuration_old"
    - open Extension Manager and remove all extensions
    - install Developer Toolbox extension
    - start DW and check if the problem still occurs
    regards,
    Ionut

  • Loops and arrays

    Hi
    I'm trying to write a loop that does the following :-
    Takes an array of index values that applies to a string adds one to the value of the index and then returns the character in this position.
    There are only four types of character within the string so I have tried to solve it with the following code:-
    for (int i=0; i < indexa.length; i++)
        if(genome.charAt(indexa[i] + 1) == 'a')
            indexia[i] += indexa;
    else if(genome.charAt(indexa[i] + 1) == 'c')
    indexic[i] += indexa[i];
    else if(genome.charAt(indexa[i] + 1) == 'g')
    indexig[i] += indexa[i];
    else if (genome.charAt(indexa[i] + 1) == 't')
    indexit[i] += indexa[i];
    I'm trying it this way but it does'nt seem to work - I've only succeeded in confusing myself - any tips would be much appreciated

    Sorry, I should have explained it better.
    The situation I've got is something like this:-
    I've got a string that looks something like this
    'aactgctcct'
    next - I've got four different arrays, each corresponding to the index of each character a, c, t and g
    so they look something like this
    indexa = {0,1}
    indexc = {2,5,7,8}
    indext = {3,6,9}
    indexg = {4}
    I am presently stuck at the next part - for which I have to return the character that is to the immediate right of the index value in the string that was analysed initially.
    e.g. for indexa ;
    0 = a
    1 = c
    for indexc;
    2 = t
    5 = t
    7 = c
    8 = t
    etc
    I don't know if this makes my predicament any clearer - I'm a genetics student this java is very new to me - I'm kinda muddling through but this bit has got me stumped !!!

  • Loops+checking arrays

    i am adding a string to an array but first have to check if it is already present.
    The code i had was trying is
    //B is capacity of array
    //adding from B downwards
    //add is set when a new string is added
    for(int search = B; search != add; search--){
    if((t0.getInfo().toString()).compareTo(getKids2()) != 0)
    ADD code                    
    so if my array is [     ,     ,    ,    , rabbit] search is 5, add is 4
    and my string to add is fish, how do i get it to loop, so it checks all the contents present in the array before it adds and if it is present breaks out the loop.     
    Rabbit is added before this code when i check if the arrays first location is null
    Thanx                    

    Why not try using a HashSet instead of an array. When you try to add a string that is already in the collection the HashSet will not add the string and will return false. Here is some sample code of how it works:
    public class test {
    public static void main(String[] args) {
       java.util.HashSet abs = new java.util.HashSet();
       String one = "One";
       String two = "Two";
       String three = "Three";
       String one2 = new String("One");
       String one3 = "One";
       System.out.println("Start Adding ");
       System.out.println("add one = " + abs.add(one));
       System.out.println("add two= " + abs.add(two));
       System.out.println("add three = " + abs.add(three ));
       System.out.println("add one2 = " + abs.add(one2 ));
       System.out.println("add one3 = " + abs.add(one3 ));
       System.out.println("add one = " + abs.add(one));
       System.out.println("End Adding");
       java.util.Iterator itr = abs.iterator();
       System.out.println("Start getting");
       while (itr.hasNext()) { System.out.println((String)itr.next()); }
       System.out.println("End getting");
    }//End main
    }//end class

  • Using while loops instead of for loops in arrays?

    I am new to java and doing a java tutorial on using arrays and for loops. What im trying to find out is how it is possible to use a while loop instead.
    I would be very grateful if anyone can suggest a way of changing my code to use a while loop.
    The code I have written is:
    public class DetermineGrade
    public static void main(String[]args)
    final char[] mark = {'A','B' ,'C' ,'D' ,'F' };
    char [] grade = new char[5];
    int [] Score ={95,35,65,75};
    for (int i=0; i<4; i++)
    if (Score >= 90)
    grade= mark[0] ;
    else if (Score >=80)
    grade = mark[1] ;
    else if (Score >=70)
    grade = mark[2] ;
    else if (Score >=60)
    grade = mark[3];
    else grade = mark[4];
    for (int i=0; i<4; i++)
    System.out.println("grade = " + Score + ", " + grade);
    Thankyou LB

    Im trying to underdstand the differences in the
    different loops. I can grasp the for loop but I dont
    see how a while loop works, or how it id different
    from the other?
    for (j = INIT; j < MAX; j++) {
        // do stuff
    }is the same as
    j = INIT;
    while (j < MAX) {
        // do stuff
        j++;
    }Lee

  • How do I set a variable within a 'for' loop grid array

    I'm afraid I'm stuck again!
    The next stage in the animation that I'm working on,  is to set up a boolean, 'drilled = false', so that all instances of the attachMovie ('openCircle') have a boolean 'drilled = false' associated with them. Then when someone clicks on one of the instances of the attachMovie ('openCircle'), the boolean becomes 'drilled = true', but only for that instance that has been clicked.
    What I've done is to set the variable (boolean)(highlighted in bold below) within both 'for' loops within the grid array, but it just returns an undefined value. Do I need to setup a separate array? (see code below):-
    //set up grid for solid array
    var spacing:Number = 5.75;
    var cols:Number = 20; // number of columns in grid
    var rows:Number = 20; // number of rows in grid
    var leftMargin:Number = 154;
    var topMargin:Number = 169;
    var depth:Number = 100; // starting point for depth
    var drilled:Boolean;
    for (i=1; i<=rows; i++) {                                                                                                         
    for (j=1; j<=cols; j++) {                                                                                                                              
              drilled[rows,cols]=false;
                        trace(drilled);
              current = attachMovie("openCircle_mc", "openCircle_mc"+i+"_"+j, depth++);
              current._x = leftMargin + ((i-1) * (spacing + current._width));
              current._y = topMargin + ((j-1) * (spacing + current._height));
              current.row=i;
              current.col=j;
    //          current.oil = Math.floor(Math.random()*1.1);  // about 1/10 objects have oil=1, 9/10 oil=0
              //open circle initially invisible, visible on rollOver
              current._alpha = 0;
              current.onRelease=function(){
                        trace(this.row+" "+this.col);
       current.drilled = true;
              current.onRollOver = function() {
                                     this._alpha = 100;
              current.onRollOut = function() {
                                     this._alpha = 0;
    I'd be grateful for any help. Thanks.

    I'm sorry for asking this question again, but I really need to have the 'drilled' variable to be available at all times outside the openCircle_mc, so if I can set up the 'drilled' variable as an array that would be good. Below is the code that isn't working:
    /*  set all values of 'drilled' to false  */
    var col:Number = 20; // number of columns in grid
    var row:Number = 20; // number of rows in grid
    for (g=1; g<=row; g++) {
              for (h=1; h<=col; h++){
                          drilled[g,h] = false;
    Very many thanks

  • Result set looping and arrays??????????

    Hey i have a result set problem in using an applet connected to a database.
    After i have accessed a database, i am using a result set to store these values, then put them into arrays to out put to screen. im using:
    count = 0;
    while(rs.next())
    lecturer[count] = rs.getString("FirstName") + " " + rs.getString("Surname");
    room[count] = rs.getString("Room_No");
    sentence = rs.getString("Subjects");
    if(sentence.length()>12)
    space = sentence.indexOf(" ");
    subject[count] = sentence.substring(0,(space));
    subject2[count] = sentence.substring((space+1),sentence.length());
    else
    subject[count] = sentence;
    subject2[count] = " ";
    timeslot[count] = rs.getInt("Time_slot");
    count++;
    resCount++;
    rs.close();
    stm.close();
    The while is there untill there are no more values in the result set. This should work(in theory). But for some reason the while loop goes around and around until 'size' (which is the size for all the arrays) is reached. This is a set value at the start of the applet. But whenever i change it the while loop goes around that many times without fail. this results in duplicate outputs to screen, that i dont want.
    Anyone got any ideas????????????

    This flow doesn't make too much sense to me. Why are you setting an absolute limit on the length of the array, if it should really be determined by the number of rows in your resultset. It sounds like you would be better off using a Collection class, like:
    List names = new ArrayList();
    while(rs.next()) {
      names.add(rs.getString("name"));
    }

  • Looping over arrays?

    Hello,
    I have a report which gives monthly totals of peoples
    production which is categorized and totaled. I also need the
    categories to have a Year to Date total with a combined year to
    date total. Doing this with queries is easy, but has a huge effect
    on load time. I am new to arrays and curious if this would be the
    correct direction. Each person on the report has a reportOrder
    which is sequential to the order on the report. If i had year to
    date totals with the report order (YearToDateUser[1] ,
    YearToDateUser[2], YearToDateUser[3]), is there a way to loop thru
    to output in the same order? Is this the wrong way to skin this
    cat? Any ideas would be greatly appreciated.
    Thanks,
    Matt

    Silly me....That was simple.
    <cfloop from="1" to="#qryGetOrder.recordcount#"
    index="i">
    <td
    class="wt"><cfoutput>#ArraySum(yeartodatepersons
    )#</cfoutput></td>
    </cfloop>
    Sorry to bother you all.

  • Experimenting with looping through array

    I've got this piece of code to check if some input of monosyllabic or not. Hope I can explain my problem with it. What it now does, is keep track of every first and last position of a vowel in the input. For a word like "bed", it works fine. The first position of an 'e' is the same as the last one, so it says "input is monosyllabic. (I'm not writing the program for English, so for those of you wondering how to recognize the monosyllabicity of "race" for example, that's irrelevant). And of course I still need to account for words like "breed", with two consecutive vowels.
    The thing is however, that the for loop keeps track of the first and last position of every vowel in the array. If a vowel from the array is not in the input, it prints "-1". Now what I want it to do, is keep track of the first and last position for 'a' vowel, and not for every vowel. So now for an input like "universe", the println(first/lastVowel) prints several lines. Being the first and last position of 'u', the first and last of 'i' and of 'e'. Because the first and last position of 'u' is equal, it also prints "input is monosyllabic".
    How do I let the for loop only keep track of the first vowel and the last vowel it encounters, and not creating a specific integer value for each vowel defined in the array?
    {code}char [] vowels = {'a', 'e', 'i', 'o', 'u'};
         for (char item : vowels){
              int firstVowel = input.indexOf(item);
              int lastVowel = input.lastIndexOf(item);
              System.out.println(firstVowel);
              System.out.println(lastVowel);
              if (!(firstVowel==-1) && !(lastVowel==-1) && firstVowel==lastVowel){
                   System.out.println("input is monosyllabic");
         }{code}

    Igor_Pavlove wrote:
    I've got this piece of code to check if some input of monosyllabic or not. Hope I can explain my problem with it. What it now does, is keep track of every first and last position of a vowel in the input. For a word like "bed", it works fine. The first position of an 'e' is the same as the last one, so it says "input is monosyllabic. (I'm not writing the program for English, so for those of you wondering how to recognize the monosyllabicity of "race" for example, that's irrelevant). And of course I still need to account for words like "breed", with two consecutive vowels.
    The thing is however, that the for loop keeps track of the first and last position of every vowel in the array. If a vowel from the array is not in the input, it prints "-1". Now what I want it to do, is keep track of the first and last position for 'a' vowel, and not for every vowel. So now for an input like "universe", the println(first/lastVowel) prints several lines. Being the first and last position of 'u', the first and last of 'i' and of 'e'. Because the first and last position of 'u' is equal, it also prints "input is monosyllabic".
    How do I let the for loop only keep track of the first vowel and the last vowel it encounters, and not creating a specific integer value for each vowel defined in the array?
    {code}char [] vowels = {'a', 'e', 'i', 'o', 'u'};
         for (char item : vowels){
              int firstVowel = input.indexOf(item);
              int lastVowel = input.lastIndexOf(item);
              System.out.println(firstVowel);
              System.out.println(lastVowel);
              if (!(firstVowel==-1) && !(lastVowel==-1) && firstVowel==lastVowel){
                   System.out.println("input is monosyllabic");
         }{code}You have a couple of problems with this:
    1 - notice that your firstVowel and lastVowel variables are defined within the scope of your for loop so they fresh and new for each iteration of the loop. So if you never get any result other than that of 'u'. (except for the print, but you don't have any results you can actually use)
    2 - for firstVowel, you just need to check if your return from your (indexOf is less than firstVowel) and (firstVowel not equal to -1): for your lastVowel you do the same but check for greater than.
    To accomplish this you have to take the definition of your firstVowel and lastVowel outside of your for loop, you'll also need to use a variable to catch your indexOf so you can do the comparison for firstVowel and lastVowel.

  • Looping through arrays

    Hello,
    I am developing a program which contains redundant code as it contains too many methods that loop through the same two dimensional array all the time.
    The reason why the code is redundant is because I need to perform a different action to different values in the array each time (depending on whether statement is true or false).
    What I want to try and do is create one single method which loops through the array and returns a boolean value.
    The method needs to take something like an if statement as a parameter so that I can stop searching through the array when the value of some element in array satisfies the if statement.
    How do I do this? How do I cut down the amount of code that searches through the same array all the time.
    Hope someone can understand
    Thanks

    Are you looking to do something like this?
    interface Predicate {
        boolean apply(int arg);
    class IsEven implements Predicate {
        public boolean apply(int arg) {
            return arg % 2 == 0;
    public class PredicateExample {
        public boolean searchMaxtrix(int[][] m, Predicate p) {
            for (int[] row : m)
                for(int x : row)
                    if (p.apply(x))
                        return true;
            return false;
    }

  • Looping through array

    If I declare an array such as the one below.
    declare
    type array_type is table of varchar2(100) index by binary_integer;
    component_array array_type;
    begin
      component_array(12345) := 'One';
      component_array(12347) := 'Two';
      component_array(12349) := 'Three';
      for i in component_array.FIRST .. component_array.LAST
      loop
        dbms_output.put_line(component_array(i));
      end loop;
    end;Is there a way to loop through only the existing binary_integer indeces? For example, if you execute the block above, you'll get an error because the loop iteration is hitting 12346 which of course doesn't exist. Other than the workaround below, is there another way using any type of array method?
    declare
    type array_type is table of varchar2(100) index by binary_integer;
    component_array array_type;
    begin
      component_array(12345) := 'One';
      component_array(12347) := 'Two';
      component_array(12349) := 'Three';
      for i in component_array.FIRST .. component_array.LAST
      loop
        begin
          dbms_output.put_line(component_array(i));
        exception
          when NO_DATA_FOUND then
            null;
        end;
      end loop;
    end;
    Thanks.

    Hi,
    Not to hijack this thread, but, since this is related to my answering OP's question, I am posting here.
    How come this code is erroring out?
    DECLARE
      TYPE array_type IS TABLE OF VARCHAR2(100) INDEX BY VARCHAR2(1000);
      component_array array_type;
    BEGIN
      component_array(12345) := 'One';
      component_array(12347) := 'Two';
      component_array(12349) := 'Three';
      FOR i IN component_array.first .. component_array.last LOOP
        IF component_array.exists(12345) THEN
          dbms_output.put_line(component_array(i));
        END IF;
      END LOOP;
    END;errors out with no_data_found, but, this doesn't ?
    DECLARE
      TYPE array_type IS TABLE OF VARCHAR2(100) INDEX BY VARCHAR2(1000);
      component_array array_type;
    BEGIN
      component_array(12345) := 'One';
      component_array(12347) := 'Two';
      component_array(12349) := 'Three';
      FOR i IN component_array.first .. component_array.last LOOP
        IF component_array.exists(12344) THEN
          dbms_output.put_line(component_array(i));
        END IF;
      END LOOP;
    END;notice the static numbers in the .exists parameter....

  • Name of String var passed to a for loop?  Array question

    I have a series of String variables named q1String where 1 can be replaced by a value from 1 to 17.
    So I have a for loop:
    for (var i=1;i<18;i++){
    var question_caption_mc:Question_caption_mc = new Question_caption_mc;
    *question_caption_mc.caption_question_string.text=q+i+String;*
    The bold line is causing an error because q is being evaluated separately, i is being evaluated separately, and String is being evaluated separately.  I probably should use a different identifier in my variable definition than String but I was wondering how to properly pass the variable name into the for loop so that
    "question_caption_mc.caption_question_string.text" will equal the value of the variable q1String through q17String.  I know this is simple but I can't seem to figure out how to query this on a web search for a similar thread or solution.
    Can anyone help me solve this?
    Regards,
    -markerline

    Okay, I came up with something that produces the start of the result:
    for (var i=1;i<18;i++){
    var newQStringArray:Array = new Array("q",i,"String");
    var question_caption_mc:Question_caption_mc = new Question_caption_mc;
    var tempArray=newQStringArray;
    var tempString=tempArray.join("");
    question_caption_mc.caption_question_string.text=tempString;
    trace(tempString);
    the trace command comes up with all of the variable names.  However I would like
    question_caption_mc.caption_question_string.text
    to evaluate to the value of tempString or rather q1String through q17String.

  • Loop through Array structure - using xpath

    Hello,
    My BPEL process logic is as follows:
    a. Extract data into variable - receiveMessageInputVariable
    The variable 'receiveMessageInputVariable' in turn has data in array structure. (set of items)
    b. Transform the data to target structure
    c. Call target partner link to store extracted data into varaible 'ServiceInputVariable'
    The variable 'ServiceInputVariable' structure is similar to 'receiveMessageInputVariable'
    In the BPEL process 'at process' level - I have catch-all exception handler - which must send the list of 'items' which failed during a BPEL instance.
    i. If my email body has the following code as below:
    <%bpws:getVariableData('receiveMessageInputVariable','XXINV_ITEM_PAY_ROW_TYPE','/ns4:XXINV_ITEM_PAY_ROW_TYPE/ITEMLINE/ITEMLINE_ITEM/ITEM_NUMBER')%>
    It successfully fetches only the first item_number record of the array structure. But does not fetch the other records in the array.
    ii. Similarly, I wish to print all the items (as received) to be available in the email body in the following pattern:
    <%"Record One-"%>
    <%bpws:getVariableData('receiveMessageInputVariable','XXINV_ITEM_PAY_ROW_TYPE','/ns4:XXINV_ITEM_PAY_ROW_TYPE/ITEMLINE/ITEMLINE_ITEM[1]/ITEM_NUMBER')%>
    <%"<br/>"%>
    <%"Record Two-"%>
    <%bpws:getVariableData('receiveMessageInputVariable','XXINV_ITEM_PAY_ROW_TYPE','/ns4:XXINV_ITEM_PAY_ROW_TYPE/ITEMLINE/ITEMLINE_ITEM[2]/ITEM_NUMBER')%>
    <%"Record Nth-"%>
    <%bpws:getVariableData('receiveMessageInputVariable','XXINV_ITEM_PAY_ROW_TYPE','/ns4:XXINV_ITEM_PAY_ROW_TYPE/ITEMLINE/ITEMLINE_ITEM[N]/ITEM_NUMBER')%>
    Please suggest a suitable syntax in my email body - which can loop through all itemline_item array and print all the item_numbers.
    (pseudo code below)
    for i in 1 .. ora:countNodes(bpws:getVariableData('receiveMessageInputVariable','XXINV_ITEM_PAY_ROW_TYPE','/ns4:XXINV_ITEM_PAY_ROW_TYPE/ITEMLINE/ITEMLINE_ITEM/ITEM_NUMBER'))
    loop
    <%"Item Number-"%><%bpws:getVariableData('i')%>
    <%bpws:getVariableData('receiveMessageInputVariable','XXINV_ITEM_PAY_ROW_TYPE','/ns4:XXINV_ITEM_PAY_ROW_TYPE/ITEMLINE/ITEMLINE_ITEM/ITEM_NUMBER')%>
    end loop;
    Thanks,
    Santhosh

    Hi Santhosh
    Try with the following approach. It may work for you
    1. Create one XSD, for the HTML content
    <xsd:element name="HTML">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="C1" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy="${eol}">
    </xsd:element>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    </xsd:schema>
    2. Create one XSL, may be you have to do this manually, as JDev will not support HTML transformations. This XSL will map your input XML to an HTML format.
    3. Create one variable in BPEL of type in the above XSD
    4. Use assign activity to assign the XSL transformation to the variable defined in Step#3
    <from expression="ora:processXSLT('HTMLTransformation.xsl',bpws:getVariableData('Variable_Input',INPUT_TYPE'))"/>
    <to variable="invokeWriteHTMLService_Input" part="HTML" query="/ns6:HTML/ns6:C1"/>
    5. Copy the variable to the email body variable
    <copy>
    <from expression="bpws:getVariableData('invokeWriteHTMLService_Input','HTML','/ns6:HTML/ns6:C1')"/>
    <to variable="varNotificationReq" part="EmailPayload"
    query="/EmailPayload/ns8:Content/ns8:ContentBody"/>
    </copy>
    Basically, the above approach converts your input to a string value whose content is a complete HTML, and you will use only one value to assign to the email body.
    Note: Please change the Variable names/XPATH Expressions/XSL file name/element names etc according to your BPEL
    Hope this helps you
    Regards
    Ayon

Maybe you are looking for