Download User manual

Transcript
Datasources
Registration of the fields
In the case of a XML datasource, the definition of a field in the report needs,
besides the type and the name, a particular expression inserted as a field description.
As the datasource aims always to one node of the selected node set, the expressions
are “relative” to the present node.
To select the value of an attribute of the present node, the following syntax is used:
@<name attribute>
For example to define a field where to store the id of a person (attribute id of the
node person), it is sufficient to create a new field, to name them with a whatever
name and to set the description to:
@id
In a similar way it is possible to get to the child nodes of the present node. For
example, if you want to refer to the lastname node, child of person, use the
following syntax:
lastname
To move to the parent value of the present node (for example to know the category
name to which a person belongs), use a little bit different syntax:
ancestor::category/@name
The “ancestor” keyword indicates that you are referring to a parent node of the
present node, in particular you are referring to the first parent of category type, of
which you want to know the value of the name attribute.
Now, let’s see everything in action. Prepare a simple report with the registered
fields as in table 10.6.
Field name
Description
ID
@id
LASTNAME
lastname
FIRSTNAME
forname
CATEGORY
ancestor::category/@name
Table 10.6 Table of conversion of the SQL and JAVA types
Type
Integer
String
String
String
Position the different fields into the detail band (as in figure 10.11). The XML file
used to fill the report is that shown in table 10.2. The Xpath expression for the node
set selection specified in the definition of the connection is:
/addressbook/category/person
The final result is viewable in figure 10.12.
111