Previous Page Next Page
Working with XML Connections in a Catalog
Setting up XML connections in a catalog
Adding more tables to an XML connection
Managing the tables in an XML connection
This document shows how to set up XML connections in a JReport catalog to get data from XML data sources, and manage the tables that are transformed from the XML data sources in the JReport catalog.
Setting up XML connections in a Catalog
To set up an XML connection to connect a JReport catalog to an XML data source, follow the steps below:
- Create a catalog or open a catalog.
- In the Catalog Manager, right-click the node of a data source and choose Add XML Connection from the shortcut menu.
If you want to set up the connection in a new data source in the catalog, select any of the existing catalog data sources, click New Data Source on the Catalog Manager toolbar, then in the New Data source dialog, specify the name of the data source, select the XML connection type and click OK.
The XML Connection Wizard appears.

- In the Import XML Schema screen, specify the way to import the XML schemas from the Schema Type drop-down list: Import from XSD or Parse from XML Instance.
- Provide the required information for importing the XML schemas.
- If Import from XSD is selected in the Schema Type drop-down list:
- In the Schema Name text box, input the URI string of the schema file or click Browse to select the file.
In the URI string, you can reference parameters and constant level formulas in the current catalog data source and the special field User Name in the format "@fieldname". For example, if a URI string is http://localhost:8080/rest/getData?startDate=2016-01-01
, and you want to use the parameters pHost, pPort and pStartDate to dynamically generate the URI at runtime, then the URI string will be http://@pHost:@pPort/rest/getData?startDate=@pStartDate
. Moreover, if a URI string contains characters, such as @, '.' or double quotation marks, or other strings that do not need to be parsed, quote them with double quotation marks. If needed, you can click New Parameter to create a parameter in the current catalog data source and reference it in the URI string. If the special field User Name is used, when clicking Next in the connection wizard, the Security Identifier dialog will pop up for you to specify the user name with which to generate the stream in JReport Designer. When running reports created on the XML data in JReport Server, the real user's ID will be used.
- When the specified URI string begins with
http://
or https://
protocol, the RESTful button is activated. Click it to specify the RESTful options for the schema file in the RESTful Data Source Options dialog.

- To receive the remote data via REST Web Service, check Via REST Web Service, then from the MIME Type drop-down list, select the MIME type for the REST Web Service data source. You can also input the type in the text box directly. The remote data will then be provided by the REST Web Services on the application server, and the REST Web Service Client API (such as JAX-RS client API of Java EE) will be used to get the remote data.
When Via REST Web Service is unchecked, the remote data will be received via the protocol in the URL you specify in the Schema Name text box in the connection wizard.
- Input the user name and password for remote data authentication.
- Click HTTP Advanced Options to specify the advanced HTTP options.
- Select an HTTP method from the Method drop-down list to send the request, which can be GET or POST.
- Click
above the Headers box to add a header line, then specify the name and value of the user defined HTTP header. Repeat this to edit more headers.
- In the Body box, specify the user defined HTTP body.
- When editing the HTTP headers and body, you can reference the parameters and constant level formulas in the current catalog data source and the special field User Name in the format "@fieldname". If needed, you can click
to create a parameter in the current catalog data source and reference it in the header or body. When parameters and formulas are referenced, you can click the Edit Format button to edit the format of their values.
- Click OK to apply the specified RESTful data source options and return to the XML Connection Wizard.
- From the Starting Node drop-down list, specify the starting node accordingly.
- Specify the XML instance file.
To use an instance file from URI, check the URI radio button, then input the URI string in the Instance text box or click Browse to select the instance file. You can also reference parameters, constant level formulas and the special field User Name in the URI string. When the specified URI string begins with http://
or https://
protocol, the RESTful button is activated. Click it to specify the RESTful options for the instance data.
To use an instance file from a user defined interface, check User Defined, then provide the class name with package name in the Class Name field. You can also click Browse to find the class file. The class you enter must exist and can be found by JReport Designer and JReport Server at runtime, which means the class should be in the class path of the system environment. After filling in this field, the class name of the interface that the class implements will be displayed automatically behind "The class implements:". Then specify the parameter string for the user defined interface in the Parameter box. The parameter string must match the format defined in the class. You can also reference parameters, constant level formulas, and the special field User Name in the parameter string.
- Check Validate with schema before fetching to validate whether or not values in the XML instance are valid according to the W3C standard and the selected XSD schema.
Notes:
- If a value of DateTime data type is accurate to millisecond, although the value is valid according to the W3C standard, a message - Invalid Value still pops up. You can ignore the error message and continue the transformation steps.
- If you use a parameter to dynamically specify an XML instance at runtime, the XML instance will be validated at runtime rather than in the importing process.
- If Parse from XML Instance is selected in the Schema Type drop-down list, input the URI string of the XML instance in the Schema Name text box or click Browse to select it. In the URI string, you can reference parameters, constant level formulas and the special field User Name. When the specified URI string begins with
http://
or https://
protocol, the RESTful button is activated. Click it to specify the RESTful options for the instance data.
- Click the Time Zone and Locale button to specify the time zone and the locale for the XML instance in the Time Zone and Locale Options dialog.
- When parameters and formulas are referenced in the URI/parameter string, click the Edit Format button to edit the format of their values if needed.
- Click Next to go to the next screen.
- In the Modify Schema Properties screen, supplement and modify the element properties as required and then click Next.

- In the Transform XML Schema screen, select an XPath to be the transforming start point. Click Next.

- In the Transformed Relational Schema screen, check the transformed result, and then click Next.

- In the Add Table screen, add the required tables to the connection, and check the Generate the default pre-join path checkbox for generating default pre-join paths for the tables. A table contains fields mapped to attributes, simple elements, contents of complex elements, and other nodes in the XML data source.

Queries and business views can be created based on these tables and a report is developed from a query (or something else which is functionally similar) or from a business view.
- Click Finish to confirm the transformed result and finalize the transformation process.
Adding more tables to an XML connection
When an XML connection is set up, you can add more tables transformed from the XML data source into the JReport catalog via the XML connection.
- Do one of the following:
- Right-click the XML connection and select Add Tables from the shortcut menu.
- Right-click the Tables node of the XML connection and select Add Tables from the shortcut menu.
- Right-click an existing table in the XML connection if there is and select Add Tables from the shortcut menu.
- Right-click any folder in the Tables node of the XML connection if you have already created some and select Add Tables from the shortcut menu.
- Select the Tables node of the XML connection, or any existing table or folder in the connection and click Add Tables on the Catalog Manager toolbar.
The Add Tables dialog appears.

- Click the Refresh button. The tables contained in the schema that is transformed from the XML file will then be displayed in the Tables box.
- Choose the required tables in the Tables box, and then click Add.
To choose consecutive tables, click the first table, press and hold down the SHIFT key, and then click the last table. To choose tables that are not consecutive, press and hold down CTRL, and then click each table.
- After adding the required tables, click Done to close the dialog.
Managing the tables in an XML connection
For the tables that have been transformed from an XML data source and added into a JReport catalog via the specified XML connection, you can refresh them, organize them into folders, and remove and add the table columns the same as you do on tables from a JDBC database.
Previous Page Next Page