### Developing reports from HDS

When you use hierarchical data sources to create reports, you need to be aware of its limitations and unique features. For example, reports created from an HDS are automatically grouped, and an HDS cannot be directly used to create charts and crosstabs. That is to say, if you want to create a chart or crosstab from an HDS, you will need to put it in a banded object, which is created on the HDS, and make the chart/crosstab inherit the dataset of the banded object.

To develop a report from an HDS:

1. Make sure the catalog where the HDS is located is open, then click the New Page Report button on the Standard toolbar.
2. In the New Page Report dialog, specify the title and layout of the first report tab in the report as required, then click OK.
3. In the Data screen of the report wizard, choose the HDS with which you want to build the report tab.
4. Follow the report wizard to create the report tab.

The following are two specific examples about developing reports from HDS.

#### Example 1: Developing a report from an HDS with dynamic XML URI

1. Click File > Catalog Management > Open Catalog to open an existing catalog.
2. In the Data tab of the Catalog Browser, expand the data source to which to add the HDS.
3. Right-click the Parameters node and select Add Parameter from the shortcut menu.
4. In the Create Parameter dialog, enter a name for the parameter, choose String as the Value Type, and in the Prompt Values box, type in the URI of the XML file from which you HDS will be imported (for details, see Creating a parameter).
5. Right-click the data source node in the Catalog Brower, and then select Add XML Hierarchical Data Source.
6. In the Import XML Hierarchical Data Source dialog, browse for the XML file. Then in the XML URI box, type in @ParameterName. For example, if you named the parameter in step 2 as XML_URI, here you should type in @XML_URI. In the XSD URI box, specify the URI of the corresponding XSD file. Then click OK (for details, see Importing the XML format HDS to a catalog).
7. Create a report with the imported HDS. When you view the report, type in the URI of the XML file which matches the XSD file in the parameter. The report will then display the corresponding data.

In addition, you can also use another way to develop report with dynamic XML URI as explained below:

1. In the Catalog Browser, import an XML HDS with an XSD file, and then create a report with the imported HDS.
2. Create a parameter using the above method.
3. In the Catalog Browser, go to the node of the imported HDS, expand the Properties sheet, and then change the property URI to @ParameterName.
4. Now you can view the report with dynamic XML file.

#### Example 2: Developing a report from a parallel HDS

The method for developing a report from a parallel HDS is the same as from a general HDS. However, take note of the following when building reports from parallel HDSs.

Groups in parallel HDS

When you insert a group by field, its children will also be inserted.

The parallel structure in the parallel HDS is represented as groups in JReport Designer. So, when you develop a report from a parallel HDS, it will automatically be grouped. By default, JReport Designer will use the first found field as the group by field. Note that you can neither add a new group by field nor remove the group by fields that are automatically added. However, if there is more than one field available to with which to group the sub-tables, you can replace the group by field with one of the other available fields.

Rules for inserting an object

- Objects in different branches should be placed in the banded object panel they belong to. That is, a banded object panel cannot hold objects which belong to different branches.
- The children of a branch, including the columns, formulas, summaries, sub-branches, and children of the sub-branches, can be inserted into any of their parent panels. If the parent panel is shared by more than one branch, that is, if the parent panel works as a trunk (global panel), it can be shared by the children of all the branches it holds. However, note that each instance of a panel, such as a report/page/group header/footer panel, and detail panel, can only hold the children from the same branch. If you want to insert the children of different branches into the shared global panel, you will have to create as many instances of this panel as per the number of branches, and then insert the children of each branch into these panels.
- Where a formula/summary can be inserted depends on the branch attributes of the formula/summary. Generally speaking, when a formula/summary creates relationships with a column, it will obtain the same branch attributes as those of the related column, and it can be placed in the panels where the column can be placed.

  A global formula, which is not associated with any branch columns, can be placed to any position of the report.

  - When you remove a branch using the report wizard, the related panel will also be removed.
  - A chart based on a field can only be placed in its own panels, which include most of the global panels, except for the detail panel.
  - A crosstab must be built upon data of the same branch, and it should be placed in the location where the branch data resides.
  - Where a text box object can be inserted depends on the branch attributes of the columns (formulas/summaries) that it contains. A text box object can hold only the data of the same branch.

Notes:

- As hierarchical data sources can only be used to create banded objects, in the New Page Report dialog, you can only choose to create a standard banded, horizontal banded or mailing label report using the report wizard.
- Since reports created from HDS are automatically grouped, in the Group screen of the banded wizard, you can neither add more groups by fields nor remove the existing ones. However, you can make changes to the existing group criteria. For example, you can replace a group by field with another one.
- When you want to publish reports created from XML format hierarchical data sources to JReport Server, the following method is recommended:
  1. In the Catalog Browser, select the HDS that is used by the report from the Hierarchical node, and then expand the Properties sheet.
  2. Change the URI property of the HDS to a relative path, for example, leaving only the name of the XML file.
  3. Create a new folder, and copy the report, the catalog, the XML file and the XSD file (if any) to the newly created folder.
  4. Click File > Publish and Download > Publish to Server to publish the folder (for details, see Publishing resources remotely).
  5. Start JReport Server. You will now be able to run the report on it.