6.1.1 Defining an XML Data Source

Creating an XML data source in Style Studio is similar to the creating a JDBC data source.

Walkthrough

To create an XML data source named “MyPersonnel,” follow the steps below:

1. Click the 'New' button in the Style Studio toolbar. This opens the 'New Asset' dialog box.

2. In the left panel, select the 'Data Source' node, and in the right 'Types' panel select 'XML'. Click 'OK'. This opens the 'XML Data Source Wizard'.

3. Click the General tab. Enter “MyPersonnel” for the data source 'Name'.

 

4. Click the Source tab. Enter a data source URL. (For this example, “file:///$INSTALL_DIR$/examples/docExamples/datasource/data/personnel.xml”.)

An XML data source can get its data from any URL. In particular, it can communicate with an HTTP server using the POST or GET methods to pass parameters to the server side program. A DTD or XML schema must be specified for the XML data stream.

You can use a variable in the URL field, e.g., 'file:///c:/datafiles/$(parameter_name)' to make the data source URL dynamic (in part or whole). Parameters can be specified in one of three ways: (1) as system variables, (2) as report parameters within the sree.properties file or (3) as URL parameters. The report engine will look for the parameters in the above sequence, and if not found, will default to prompting the user for the parameter.

5. Select the HTTP method. If the URL does not use HTTP, select the GET method.

 

6. Select the Request tab.

7. Enter the name and the encoding of the request, “default” and “UTF8”.

Each request is bound to a pre-defined XML output type (DTD). More requests can be added after the data source has been created. A request corresponds to a particular set of parameters in the data source server. For example, a servlet may expect a 'file' parameter which contains the file name of the XML file on the server.

 

8. Select the Parameter tab.

The Parameter tab shows the current parameters for the request. For HTTP requests, the parameters are ordered in a parameter tree. The root of the tree is the 'Parameters' node. The child of the root is a sequence node, with one or more pairs of parameters. Each pair consists of a name and a value node. The name node contains the name of the HTTP request parameter, and the value node contains the value of the parameter.

Check the 'Variable' box if you want the parameter value to be a variable.

9. To add a new parameter, select the 'parameters[0]' node and click on the 'Add parameter' button. Enter the name of the parameter and its value. Repeat to add more parameters.

 

10. Select the Output tab. Click 'Browse' and choose the DTD or XSD file that corresponds to the XML file (In the example, personnel.dtd). Click 'Import DTD'.

 

11. Click 'Finish'. This closes the Wizard and creates the XML data source.

12. Select the Output tab. The output tree shows the XML schema defined in the DTD file. Because the DTD format does not specify the real type of the data in the XML elements, all elements are treated as strings by default.

See XML Element Types for more infor­mation about the types.

You do not ordinarily need to specify XML element types. This is only necessary if the element is used in the query selection conditions as a non-string type. For example, if the birthday is compared in a conditional expression with another date value, the type must be specified for the XML element, otherwise it will be treated as a string and the comparison will be meaningless.

Since only one schema is defined for each request, a request can only generate XML data in the specified schema. A separate request must be defined in the data source for each different XML output type.

13. (Optional) To manually override the element type for an element, follow the steps below:

a. Expand the 'employee' node, select the 'birthday' node, and change its type to 'date'.

 

b. Select the 'salary' node on the tree, and change its type to 'double'.

c. Set any desired format for the field (e.g., MMM-dd-yy for a date or ###.00 for a number). See Adding a Format to a Data Field for more information about format specifications.

14. Click the 'Save' button in the Style Studio toolbar to save the new data source.

Every XML data source must contain at least one request. For more complex XML data sources, it is often necessary to create multiple requests. Each request can have different parameters and a different XML output type. If the URL is not HTTP-based or does not require any parameters, simply create a request without specifying any parameters.

<< 6.1 XML Data Source © 1996-2013 InetSoft Technology Corporation (v11.5) 6.1.2 XML Element Types >>