xsltobieebi-publisheroracle-bi

Adjacent loops in row for Oracle BI Publisher


I have an xml sample similar to this:

<LIST>
<G_1>
 <EMPLOYEE_NUMBER>1</EMPLOYEE_NUMBER>
<G_2>
 <ELEMENT>Basic</ELEMENT>
 <VALUE>10</VALUE>
 <GROSS>12</GROSS>
 <TYPE>Earning</TYPE>
</G_2>
<G_2>
 <ELEMENT>Transport</ELEMENT>
 <VALUE>11</VALUE>
 <TYPE>Earning</TYPE>
 <GROSS>15</GROSS>
</G_2>
<G_2>
 <ELEMENT>Food</ELEMENT>
 <VALUE>7</VALUE>
 <TYPE>Earning</TYPE>
 <GROSS>8</GROSS>
</G_2>
<G_2>
 <ELEMENT>Tax</ELEMENT>
 <VALUE>5</VALUE>
 <TYPE>Deduction</TYPE>
</G_2>
<G_2>
 <ELEMENT>Pension</ELEMENT>
 <VALUE>3</VALUE>
 <TYPE>Deduction</TYPE>
</G_2>
</G_1>
</LIST>

Now I have created a table with 5 columns and I want to loop through all the employee records (G_1). The first 3 columns will be for G_2 records of type Earning, then the next two will be for Deduction. So we should have:

ELEMENT  |  VALUE   |   GROSS    |   ELEMENT     |   VALUE
Basic        10          12          Tax              5
Transport     11         15          Pension          3
Food          7           7

I have tried two for-each loops in my row like:

for-each:G_2[TYPE='Earnings']  ELEMENT  RESULT  GROSS end  for-each:G_2[TYPE='Deductions'] ELEMENT   RESULT end

But this only works for the first 3 columns but returns blank for the rest (Deductions). Any one have an idea of workaround? I have even tried a for and end with each column cell but that hasn't worked either.

This is basically a payslip report with earnings in one group of columns and deductions on another.

Thanks


Solution

  • I found the answer This is what I am using. As you know I want 5 columns. For each page of the report I have at the top:

    <?for-each@section:G_1?><?sort:EMPLOYEE_NUMBER;'ascending';data-type='text'?>
    

    Then at the end of the page

    <?end for-each?>
    

    These are the columns we want for the table:

    ELEMENT  |  VALUE   |   GROSS    |   ELEMENT     |   VALUE
    

    Now for each of the columns in the table (rtf document), I have:

    <?for-each-group:G_2[TYPE='Earning'];ELEMENT?><?sort:ELEMENT;'ascending';data-type='text'?>
      <?ELEMENT?>
    <?end for-each-group?>
    
    <?for-each-group:G_2[TYPE='Earning'];ELEMENT?><?sort:ELEMENT;'ascending';data-type='text'?>
    <?sum(current-group()/VALUE)?>
    <?end for-each-group?>
    
    <?for-each-group:G_2[TYPE='Earning'];ELEMENT?><?sort:ELEMENT;'ascending';data-type='text'?>
    <?sum(current-group()/GROSS)?>
    <?end for-each-group?>
    
    <?for-each-group:G_2[TYPE='Deduction'];ELEMENT?><?sort:ELEMENT;'ascending';data-type='text'?>
    <?ELEMENT?>
    <?end for-each-group?>
    
    <?for-each-group:G_2[TYPE='Deduction'];ELEMENT?><?sort:ELEMENT;'ascending';data-type='text'?>
    <?sum(current-group()/VALUE)?>
    <?end for-each-group?>