In addition to relational databases, EspressChart allows you to retrieve data and query XML files. XML data can be in virtually any format, but you need to specify a DTD file or an XML Schema (XSD) along with the XML data. To set up an XML data source, select XMLFiles node in the Data Source Manager and click the button. A dialog will open prompting you to specify options for the new XML source.
The first option allows you to specify a display name for the XML data source. The second option allows you to specify the location of the XML file from which you want to retrieve data. Note that you can also specify an XBRL file in this field. You can set up a data source that retrieves XML data from an HTTP server here as well, by adding the appropriate URL as the file location. The third option allows you to specify the location of a valid DTD or XML schema file for the XML file.
The Quadbase Format checkbox allows you to indicate whether the XML file is in the form of an XML export from EspressChart. For example, if you select to export a chart's data in XML format, you can read it back in using this format. For more on exporting to XML, see Section 8.2 - Exporting Charts. When you use a file in this format, you do not have to specify a DTD or XML Schema.
The Verify XML against DTD/XML Schema checkbox will make sure that the supplied XML file/source complies with the layout specified in the DTD or XML schema file. Because queries are designed based on the structure of the DTD/XML Schema file, a non-conforming XML source could produce unexpected results. If the XML does not conform to the DTD or XML schema, you will be given a warning. You can, however, continue setting up the data source.
The Refresh Schema checkbox will reload the schema or DTD definition to incorporate any changes to the structure in the XML data source in the registry. This option is only necessary if the DTD or schema definition has changed since the data source was first created.
Once you finish setting up the XML file and the DTD/XML Schema, a new dialog will open allowing you to specify the data type for all the selectable elements in the XML data source. The dialog will be different depending on whether you are using a DTD file or XML Schema.
Because DTD files do not specify a correct data type for elements, all elements are considered to be Strings by default. To change the data type of an element, you have to select the element and pick a data type from the drop-down window at the bottom of the dialog. To ensure proper results when you query the XML file, you should set the data type for all selectable elements. This includes leaf nodes, parent nodes that contain data, and attribute elements. The following data types are supported:
String
Integer
Double
Date (If you specify date as the data type, you will also be required to specify the date format.)
Boolean
Once you finish specifying the data types, click the
button and the XML source will be added to the Data Source Manager.If you're using an XML schema, a different data types dialog will open.
Generally, the data types should already be defined in the XML schema file, but you can make any changes in this dialog. Once you finish specifying the data types, click the
button and the XML source will be added to the Data Source Manager.Once you set up an XML data source, you can then create queries to select nodes, specify filtering conditions, and transform the tree structure into the tabular form used by EspressChart. To add a query, select the node for your XML source and click the
button. This will launch the XML query builder interface that allows you to construct a query.The first tab in the XML query builder allows you to select fields/nodes from the XML file you want to use in the chart. The left side of the window contains the tree structure from the DTD or XML schema file. You can pick any selectable elements and add them to the query by clicking the Alias field for a column and typing the new column alias.
button. Selected fields will appear in the right side of the window. You can specify an alias for any field by double clicking theNote | |
---|---|
Each selected element will become a column in the chart. For results where a one-to-one relationship cannot be determined, the tabular structure is built using all available permutations in the data (similar to a cross-join in SQL). For best results, it is recommended that you select fields for a query where a clear hierarchical relationship is present. |
The Conditions tab of the XML query builder allows you to specify some basic filtering criteria for your selection.
You can specify an equal, not equal, greater than, less than, less or equal to, or greater or equal to condition for any selectable element in the XML file. You can also use the AND and OR operators to build compound conditions. Fields are specified using a direct path down the XML tree. Currently, only direct path is supported. You cannot use more complex XPath expressions. To add a field, you can double click on it in the left side, or you can select it and click the
button.After you finish writing the conditions, click the
button to verify that the syntax is correct.The DataSheet tab allows you to preview the query result and see how the XML data is converted to tabular form. You can navigate through the result set the same way as in Query Builder (Section 4.2.2.1.6 - Query Output).
Once you select the fields and specify the appropriate conditions, click the
button. The query will then be added as a new node under your XML source in the Data Source Manager and can now be used to create a chart.There is a sample XML file and a sample DTD/XSD included in the EspressChart installation. The files are located in help/examples/DataSources/XML
directory of your installation and are called Inventory.xml
and Inventory.dtd
. There is also a sample servlet that allows you to stream XML data to the ChartDesigner. The servlet code and instructions are located in help/examples/DataSources/XML/servlet
directory.
As with database queries, you can also specify parameters for XML queries. The same syntax “:” is used to denote a parameter in the XML condition as it is in a query condition. So the following XML condition:
/Inventory/Category/@CategoryName = :category
would place a dynamic filter on the query for the CategoryName attribute. XML parameters are initialized in the same way as query parameters. The initialization dialog will appear if you try to preview or close the query, or you can trigger it by clicking the button. The only difference is that instead of mapping to a database field, the parameter prompt can be mapped to a node in the XML file.