This section will describe how the designer generates the XSL-FO code and
how you can add your own code. Note this section requires some basic
knowledge of XSLT and XPATH.
Understanding the generated code for
Each detail area (see 1 in the screenshot) in the designer will be printed
as a table:
The table has a header (see 2) which will contain the area‘s header
And a body which contains the detail area content.
The body can contain many rows which are the repetitions of the
detail area. For these many rows to happen the designer creates a XSLT
loop using the for-each expression based on the XML Node that has been
selected for the area (see 3)
In the order.xre example we can see the described structure for
the order lines:
There is a table being created if any node
/Order/OrderDetail/ListOfItemDetail/ItemDetail exists. That is
what you see right below the blue comment line (xsl:if expression).
There is a table header which contains the „Detail Columns Header“
After the loop there is the definition of the tables rows <fo:table-row
, therefore a new table row will be created of each repetition
of the loop, that is for each ItemDetail in the input XML. In
each row the fields of the area will be printed.
Further down in the code there is the end of the loop and the table
to finish the area printing
The result is:
One table header (the grey area below)
One table body with 2 rows (for 2 items in the order, since we used
an input XML file with 2 items only)
Note the code generated for the report header is similar but slightly
different in the locations.
Introduction to Variables and Keys
This section will introduce the use of XSLT Variables and Key in the
Match: is the node that the key should return. It is like a
table name in a database lookup. For example, if we have a structure
like /Persons/Person/FirstName and /Persons/Person/LastName
and we want to create a lookup to find all persons named „Peter“, we
use /Persons/Person as Node or Table.
Use: this is the index field (like an index field in a
database table). Since we are going to search by name we will use the
pay attention to the  which will store only the first returned node
(in case there are several persons with name Peter)
You can use the variable of the previous step in a field of your
area, for example setting the Xpath value to $result/LastName.
<xsl:for-each select="key('mySearch','Peter')"> : This
would return nodes 1 and 4. This creates a loop which need to be
closed with </xsl:for-each>.
Tip! You can leave the XML Node of the area empty and instead you
can use the Advanced fields (see next section) to create a custom loop for
the area as below:
We deliver an example named PersonKey.xre where you can see the
implementation of this section. Please note there are other ways
of achieving the same result without using variables or keys. The
only purpose of this example is to show these features in action.
Adding your own code
There are several way of adding XSL-FO code to your report:
The first one in the Free Code field. This allows the insertion of
code in cells, rows and tables. We will not explain it in this section
since it has already been explained in this guide.
The report initialization code can be set in the report properties,
Other tab. This field can be used to define keys or report variables.
For example we create here a variable which will contain the
order number. The variable can be used later in the report using $ordernumber.
the code will then be placed at the very top of the generated code:
Each detail area and the report header contain an Advanced tab where
you can place code in different locations. In the screenshot below we
have added XML comments to highlight the output code location.
Start Code: will be place before the table creation for the area.
Before row code: the code will be placed after the table loop and
before the row generation.
After row code: after each row repetitions
Finish code: after the loop.
The following examples show how to use some of the advanced features:
BooksGrouping2.xre: this is a „groupby“ report which
creates a master detail structure using a flat input structure. The
report groupy by the field CUSTOMER_ID to create a list of persons and
a grouped list of booked borrowed by each person
BooksGrouping.xre: This is the same example as above but
instead of using the built-in grouping functionality we group the
books using a variable. This is done by selecting „Local group“
and setting a variable to store the customer name:
last in the detail 2 area we use the variable to select the books
belonging to the current customer:
BooksAndCode.xre: This example is similar to the previous
one. The difference here is that the input XML is not one flat
structure but has 2 parallel structures that will be linked using a
In the ROWSET2_ROW nodes we have the list of customers which we will
print out, this is the main detail area. We save the current customer
in a variable for each row.
In the subarea „Detail 2“ we use the variable to select only the
corresponding records from the other structure ROWSET1_ROW.