Print reports for Oracle APEX and Apache FOP


9. The two columns example

The example tasksTwoColumns shows how to use Xpath to create a two columns report using a linear input XML file. The output will look like this:

It is a list of tasks organized in 2 columns, with the task name and the employee assign to the task.

The layout of the report is:

  • there is a detail area which will contain 2 task name fields (2 columns). Therefore the area will need to be repeated for every second task. The Xpath to achieve this is:

    ROWSET/ROW[position() mod 2 = 1]

    This will select every second „ROW“ element in the XML
  • In the area there are 2 TaskName field. The Xpath of the fields are:
    • TASK_NAME : to select the TASK_NAME field in the current ROW node
    • TASK_NAME/../following-sibling::ROW/TASK_NAME: to select the TASK_NAME field in the next ROW after the currently selected ROW (this will be the second column)

      the XPATH expression means:
      • select current TASK_NAME
      • use the /../ to select the parent node (the ROW node)
      • following-sibling::ROW: will select the next ROW
      • /TASK_NAME selects the field in the ROW