SourceForge.net Logo   FFReport

Xml Layout
 

Xml Layout

  • RecordEditor-Xml Connection
  • Report Wizard
  • Creating a report
  • RecordEditor Xml Provider
  • Defining RecordEditor Xml Provider
  • Using the RecordEditor-Xml Provider in a Report
  • One way to define a Fixed Width Flat file is via a Xml Layout This package can use a JRecord Xml Layout. Typicaly a Xml Layout looks like

       1:<?xml version="1.0" ?>
       2:<RECORD RECORDNAME="DTAR020" COPYBOOK="DTAR020" DELIMITER="&lt;Tab&gt;" 
       3:        FONTNAME="CP037" FILESTRUCTURE="Default" STYLE="0" RECORDTYPE="RecordLayout"
       4:        LIST="Y" QUOTE="" RecSep="default">
       5:        <FIELDS>
       6:                <FIELD NAME="KEYCODE-NO" POSITION="1"  LENGTH="8" TYPE="Char" />
       7:                <FIELD NAME="STORE-NO"   POSITION="9"  LENGTH="2" TYPE="Mainframe Packed Decimal (comp-3)" />
       8:                <FIELD NAME="DATE"       POSITION="11" LENGTH="4" TYPE="Mainframe Packed Decimal (comp-3)" />
       9:                <FIELD NAME="DEPT-NO"    POSITION="15" LENGTH="2" TYPE="Mainframe Packed Decimal (comp-3)" />
      10:                <FIELD NAME="QTY-SOLD"   POSITION="17" LENGTH="5" TYPE="Mainframe Packed Decimal (comp-3)" />
      11:                <FIELD NAME="SALE-PRICE" POSITION="22" LENGTH="6" DECIMAL="2" TYPE="Mainframe Packed Decimal (comp-3)" />
      12:        </FIELDS>
      13:</RECORD>
    

    There is a wizard ("Xml Layout Wizard") that will define your Xml layout by pointing and clicking at the fields in a sample file.

    As for all the interfaces in this package, there is both a IReportConnection (IReport Specific) and JRDataSourceProvider (Generic designer) interfaces to Xml-Layouts.

    For a description of the Xml Tags see "XML Tags". For some Xml examples please see "RecordEditor XML"


    RecordEditor-Xml Connection

    If using iReports, for RecordEditor-Xml Reports, you should use the RecordEditor-Xml Connection class, This can be selected in the connection Combo:


    Report Wizard

    One of the easiest ways to get started is to use IReports Report Wizard. To do this:

    1. Start iReports.

    2. Select File >> New... from the IReport top level menu (it was File >> Report Wizard in earlier versions of IReport).

    3. Select the appropriate Template and then hit the Launch Report Wizard Button

      Note: The Blank* Templates can not be used with the ReportWizard.

      Note: Quite a few of the Templates will not work with Linux, I have created Linux versions of these Templates (on Fedora 11), which should be better.

    4. Enter the report name and details in the screen, the click on the next button.


      then click on the next button

    5. Select RecordEditor-Xml Connection in the connection Combo, this will bring up the Query field and the Design Query button.


    6. Click on the Design Query button, this will bring up the RecordEditor-Xml Definition Screen. The following example is for a native Mainframe (recfm=fb) file holding Binary and Text fields:


      Field

      Description

      File

      Data file to be used in the report.

      Record Layout

      RecordEditor-Xml Layout Definition

      Build Layout Button

      Wizard to create a layout from the file. See "Xml Layout Wizard" for more details.

      Define fields as numeric

      Old field

      Report Record

      Primary report record. When this record comes up, data will be passed back to Jasper Reports Typically it will be the main detail line of the report.

      Record

      Records to be used in the Report

    7. Click the go button and the Query screen will be displayed; click on the Next button.


    8. The next screen displays the fields, select those you want


    9. Next select the Group by fields.


    10. On the second last screen, you select the Report-Layout.


    11. Once you have defined the report, make sure the Connection is RecordEditor-Xml Connection


    12. Next you need to sort the file in the same order as the Group by clause. Right click on the Report name and select the Edit Query


    13. Click on the Sort option button down the bottom of the screen.


    14. Select the Sort fields


    15. Once you enter the sort fields, exit the Query screen, your report should be ready to run. Try hitting the preview button.

    Creating a report

    Note: Make sure that you have RecordEditor-Xml Connection selection


    To create a report from scratch

    1. Start iReports.

    2. Select File >> New... from the IReport top level menu.

    3. Select the appropriate Template from the List and hit the Open this Template Button.

    4. Enter Report name


    5. Next Right click on the Report Name and select Edit Query


    6. Next Select RecordEditor in the Query Language Combo. Then hit the Query Designer Button.


    7. The RecordEditor-Xml details screen will be displayed where you can enter RecordEditor-Xml Copybook and the source file. Once finished, hit the Go button.


      Field

      Description

      File

      Data file to be used in the report.

      Record Layout

      RecordEditor Layout Definition

      Define fields as numeric

      Old field

      Report Record

      Primary report record. When this record comes up, data will be passed back to Jasper Reports Typically it will be the main detail line of the report.

      Record

      Records to be used in the Report

    8. Now if you expand the field Tree, the RecordEditor-Xml fields are listed, you can drag and drop these fields into the report


    The generated report may look something like this:



    RecordEditor Xml Provider

    I also supply the RecordEditor-Xml provider class net.sf.FFReport.Provider.RecordXmlDataSourceProvider , this implements the standard jasper reports Design interface (JRDataSourceProvider). You should be able to use this class in any Jasper Report Designer that supports this interface. In iReports you are better off using "Cobol Connection" but if want, you can try the provider class in iReports. Just be aware that JRDataSourceProvider's do not work in all versions of iReports e.g. Version 3.7.3.

    Defining RecordEditor Xml Provider

    The class net.sf.FFReport.Provider.RecordXmlDataSourceProvider implements JRDataSourceProvider and acts as the interface between iReports and the RecordDataSource (file based data source for a report).

    Steps:



    Using the RecordEditor-Xml Provider in a Report

    First you need to create a report (File >>> New), then

    1. In the Report Inspector Right Click on the report Name and select Edit Query


    2. Select the DataSource Provider Tag.  

    3. Press the Get fields from datasource to get the RecordEditor-Xml selection screen


      Field

      Description

      File

      Data file to be used in the report.

      Record Layout

      RecordEditor-Xml Layout Definition

      Build Layout Button

      Wizard to create a layout from the file. See "Xml Layout Wizard" for more details.

      Define fields as numeric

      Old field

      Report Record

      Primary report record. When this record comes up, data will be passed back to Jasper Reports Typically it will be the main detail line of the report.

      Record

      Records to be used in the Report

    4. When you have entered all the data press the go button.

    5. Now if you expand the field Tree, the RecordEditor-Xml fields are listed, you can drag and drop these fields into the report


     

    FFReport at SourceForge Download Page Forums