1

I have an XML data set produced by BI Publisher that contains two groups

Input XML:

<DS>
    <G_1>
        <TASK_NAME>IMPORTANT TASK</TASK_NAME>
        <PROJECT_DESCRIPTION>ACTIVATION</PROJECT_DESCRIPTION>
        <CS_SUM_TASK_COST>100.03</CS_SUM_TASK_COST>
        <CS_SUM_TASK_FUNDING>2000</CS_SUM_TASK_FUNDING>
    </G_1>

    <G_1>
        <TASK_NAME>IMPORTANT TASK</TASK_NAME>
        <PROJECT_DESCRIPTION>DEACTIVATION</PROJECT_DESCRIPTION>
        <CS_SUM_TASK_COST>50.00</CS_SUM_TASK_COST>
        <CS_SUM_TASK_FUNDING>5000</CS_SUM_TASK_FUNDING>
    </G_1>
    .
    .

    <G_2>
        <INVOICE_NUMBER>7000006861</INVOICE_NUMBER>
        <INVOICE_DATE>2004-03-26T07:23:49.000-05:00</INVOICE_DATE>
        <INV_AMOUNT>5.01</INV_AMOUNT>
    </G_2>
    <G_2>
        <INVOICE_NUMBER>7000006862</INVOICE_NUMBER>
        <INVOICE_DATE>2004-03-26T07:23:49.000-05:00</INVOICE_DATE>
        <INV_AMOUNT>10.01</INV_AMOUNT>
    </G_2>
    .
    .
</DS>

how do I select a different header for the INVOICE nodes?

I have tried in my RTF document the following approach

<?choose:?>
<?when://G_2[contains(local-name(), 'INVOICE')]?>
HEADER 1
<?end when?>

<?otherwise?>
HEADER 2
<?end otherwise?>
<?end choose?> 

<?body:begin?>
for each processing of G_1 nodes

<<I Want to start using the second header here>>

for each processing of G_2 nodes
<?body end?>

The header never changes.

Please assist me.

umar faraz
  • 371
  • 5
  • 18
JBOYD
  • 13
  • 1
  • 5
  • I neglected to mention that I need some values from the data set to appear in the header. In this approach @section resets all the values so they are blank in the header. It does work if I only want static text to appear in the header. – JBOYD Jan 17 '17 at 19:34

2 Answers2

1

For controlling header, use the @section command, and a global variable. Try this.

Put this code in the body.

<?for-each@section:G_1?>
<?xdoxslt:set_variable($_XDOCTX, 'HEADER', 'INVOICE')?>
<?end for-each?>
<?for-each@section:G_2?>
<?xdoxslt:set_variable($_XDOCTX, 'HEADER', 'OTHER')?>
<?end for-each?>

Now put this into the header: <?xdoxslt:get_variable($_XDOCTX, 'HEADER')?>

BIP splits the dataset with @section first, and prints the variable 'HEADER' for all the pages, until the next split is reached.

Ranjith R
  • 1,571
  • 1
  • 11
  • 11
0

This approach works for the question asked.

But I neglected to mention that I need to include values from the data set in the header and not just static text. Using @section prevents this because all the values outside for-each are reset and so are blank in the header.

I am marking this as solved for the originally posed question.

JBOYD
  • 13
  • 1
  • 5