 | Level: Introductory Laura Giddings, Principal Technical Consultant, Justsystems, Inc. Andy Stewart (andy_stewart@justsystems.com), Systems Engineer, Justsystems, Inc.
14 Sep 2006 Justsystems' xfy Enterprise Solution allows organizations to deliver information solutions easily by using xfy visual interfaces, adaptive XML templates, and by separating the visual presentation from the data handling and business rules. IBM® DB2® 9 merges performance, scalability and ease of use, expected of DB2, with storage and management of both relational and XML data. Combine xfy Enterprise Solution with DB2 9 to manage XML data in its native format and create dynamic, data-driven XML document applications. This article demonstrates, step by step, how to create three XML document applications that look like documents to your end-users, but retrieve live data from your DB2 Enterprise 9 data server.
Introduction
The record adoption of XML and evolution of database technology to natively store both XML and relational information, have revolutionized the way enterprise data can be managed and shared.
Justsystems xfy Enterprise Solutions combined with IBM DB2 9 let you manage XML data in its native format and create dynamic, data-driven XML document applications without stressing already limited IT resources.
This article takes you through the process of building three XML document applications to display customer email correspondence and sales information for different audiences with different information needs.
The first XML document application steps you through the visual query generator tool to perform both XML and relational queries that drive all three applications.
The second XML document application builds on the first application, replacing vanilla XHTML tables with the xfy Adaptive Grid template to display all email, sales, and operational shipping data.
The third XML document application builds on the second application and places one of the grid displays with the xfy Adaptive Chart template to display only the email and sales total information.
Having a product like xfy Enterprise Solution, lets you easily present the same set of information tailored to different groups within your organization without the prolonged cycle of customized software development and deployment.
The following are some key features of xfy Enterprise Solution demonstrated in this application:
- xfy Enterprise Client visual compound XML document creation tools
- xfy Enterprise Client visual query generation interface to DB2 9
- xfy Adaptive Grid and Chart templates
Some basic familiarity with databases and XML technologies is recommended to get the most from this article.
Assumptions
The xfy Enterprise Solutions Trial Edition is downloaded and installed into a directory called $XFYHOME.
IBM DB2 9 is downloaded and installed into a directory called $DB2HOME.
You have registered the xfy Enterprise Solution and have a key.
The XFYDB database has been created through the $XFYHOME/scm/scm_createdb2.bat command.
The simpleapp.zip is downloaded, and the DBSIMPLE database is created, populated, and registered with the xfy Enterprise Client. For more information, refer to the Downloads section of this article.
Create the first XML document application
The first XML document application is an XHTML page with an editable customer field that drives the selection criteria for the XML and relational database queries.
This application uses the xfy Visual XML Editor, the xfy Visual Query Generation tool, and the auto-layout presentation method, to display the selected data in XHTML tables.
- Start the xfy Enterprise Client.
- In the top menu, select File > New.
-
Select XHTML from the Standard Vocabularies templates, then click Open on the dialog box. You see a new set of tools on the toolbar and a blank screen with a flashing cursor.
Figure 1. New XHTML document
- Type Contact Sheet and press return. Highlight the text with your cursor, and click B and U in the toolbar to bold and underline the text
- In the top menu, select Table > Insert Table. Set rows to 1, columns to 2, table width to 500 pixels, and click OK on the dialog box. In column one, type Customer Name and in column two type Art LLC.
Figure 2. Insert table
- On the next line, type 1. Email History, and click Enter.
- In the top menu, select Insert > Create XML Object. Click Browse in the dialog box.
-
Click the Template icon on the left side of the dialog. Select Database DB2 under the Data Access templates, then click Include followed by OK. The result is a button in the document labeled "Query Generator." Select Database > Re-execute When Loading File from the menu.
Figure 3. Database template
Figure 4. Result - Query Generator button
-
Click Query Generator to invoke the query generator tool. Select the DBSIMPLE database, and click Next > on the dialog box.
Figure 5. Database selection dialog
-
Select SALES_DOCS for the table, and Search by record for the search units. Click Next > on the dialog box.
Figure 6. Table selection dialog
-
Click Add Operand, and click the Node icon on the left in the resulting dialog box. Select the MAIL_DOC for the column, and type /email/To/text() in the Node Path input area. Click Add and set the data type to String. Click OK to complete the dialog.
Figure 7. XML query filter dialog
-
Confirm the drop-down list is set to
Equals, then click Browse on the dialog box.
Figure 8. Query filter condition dialog
-
Click the Source icon on the left side of the dialog and navigate through the source tree on the right to find the column in the source document table, currently containing the text
Art LLC. Click OK on the dialog box. Click Next > to continue to the next dialog.
Figure 9. Tree view of XML source
-
Select the columns to be returned by the query by selecting ENTRY_DATE, then click Add. Click ENTRY_CODE, then click Add.
Figure 10. Query return value selection dialog
-
Click the Node icon to get return values from within the XML column MAIL_DOC. Select the MAIL_DOC column and type /email/From/text() in the
Node Path input area, then click Add. Type MAIL_FROM for the tag. Follow those same steps for the /email/To/text() (use MAIL_TO for the tag) and /email/Subject/text() (use MAIL_SUBJECT for the tag). Confirm that your inputs look like the Figure 11, then click OK on the dialog.
Figure 11. XML return value selection dialog
-
Set the
ENTRY_DATE to return in ascending order. Click Next > in the dialog.
Figure 12. Return value order by dialog
-
Edit the text of the query to replace the
<object> tag with a more descriptive <SALES_DOCS> tag. Click Execute in the dialog.
Figure 13. Edit query dialog
-
The result is an auto-layout table with the return columns populated with data from the XML query. This is a good time to save your work. Select File > Save As, navigate to your preferred directory and call the file simple_app1.xml.
Figure 14. Results of XML query
- On a new line, type 2. Delivery History.
- Insert a second XML database DB2 object, as done in step 8, to perform a query on a relational database table. Follow steps 9 and 10, except choose the SELLING_INFORMATION table. Click Add Operand.
-
Select the DELIVER_TO column, and click Add > OK.
Figure 15. Relational query filter
- Navigate the source tree to the
Art LLC entry, like in steps 12 and 13.
-
Click the Column icon. Select each of the columns to be returned from the SELLING_INFO table. Then, click the Add button.
Figure 16. Relational query return values
- Set the ORDER_DATE column to return in ascending order, like step 16.
- Replace the generic
<object> tags with <ORDERS>
</ORDERS>, like in step 17. Click Execute to see the SELLING_INFORMATION data displayed.
- Test the interactive nature of the document application by changing the Customer Name - Art LLC to Maugham Inc., then save the file. Press F5 to reload the file. If the re-execute flag was set correctly in step 8, then the resultant data should be specific to the Maugham Inc. customer.
$XFYHOME/doc/simpleapp/apps/app1.xml is the completed XML document application included for reference.
Create the second XML document application
The second XML document application is a modification of the first.
It modifies the data presentation by using the xfy Adaptive Data Grid template.
This is just one of the many ways the same data can be represented and adapted to different user audiences in your organization.
Before starting, save the current simple_app1.xml file as simple_app1_datagrid.xml. File > Save As > simple_app1_datagrid.xml.
- Select the table containing the email history information. It is selected properly when a dotted line surrounds the area and the Database menu becomes available.
- Select Database > Change View > Adaptive Template from the top menu.
-
Select Data Grid from the list of Adaptive templates, then click OK on the dialog box.
Figure 17. xfy Adaptive Data Grid template selection
-
The resulting dialog box shows a tree view of the returned data on the left and grid options on the right. On the tree view, select SALES_DOCS, then click Set on the right of the Repeated Element area. Expand the
SALES_DOCS in the tree view to reveal the five returned data columns. Click Add to add a Column 5 to the Column List, then one by one, select the returned data (such as EMAIL_TO), and click Set to the right of the Column Node area. Selecting the Title check box, and typing in a value (such as TO) changes the column heading for this column. Follow these steps until all five columns are mapped to the data grid.
Figure 18. xfy Adaptive Data Grid Data settings
-
Click the Options tab to set the data types and display sizes for all returned data columns
Figure 19. xfy Adaptive Data Grid option settings
- Select the Area tab on the dialog to set final display options for the data grid. Click OK on the dialog you are when satisfied with the presentation. At any time, the data grid can be edited by selecting the grid and navigating to the database top menu as follows, Database > View Style Settings.
-
Follow the same procedures for the table information under Delivery History to put that information into a data grid. Save your work to simple_app1_datagrid.xml.
$XFYHOME/doc/simpleapp/apps/app1_datagrid.xml is the completed XML document application included for your reference.
Create the third XML document application
The third XML document application is a modification of the second.
It modifies the data presentation by using the xfy Adaptive XYChart template.
In this chart, total amounts for sales orders are displayed.
This is another method to take the same data from the first query and present it to different user audiences in your organization.
Before starting, save the current simple_app1_datagrid.xml file as simple_app1_datagrid_chart.xml by going to File > Save As > simple_app1_datagrid_chart.xml.
- Change the text
Delivery History to Order History.
- Select the returned data under
Order History until the dotted line and Database menu options appear.
-
Select Database > Change View > Adaptive Template, then click the XY Chart from the list of templates.
Figure 20. xfy Adaptive XYChart template selection
- The resulting dialog lets you set the display options for the chart object.
ORDERS are again the repeated element, with ORDERED_DATE used as the X axis variable and TOTAL used as the Y axis values.
The Series sets what point types are displayed for both the chart and legend.
Figure 21. xfy Adaptive XYChart data settings
-
Select the Options tab to adjust the axis and series display options. Click OK on the dialog.
Figure 22. xfy Adaptive XYChart option settings
-
A chart with order totals has replaced the lower data grid object.
Figure 23. xfy Adaptive XYChart results
This was all accomplished without changing the underlying data, just the presentation.
The document application is still data driven - a fact confirmed by setting the Customer Name at the top to Maugham Inc, saving the document and reloading (Press F5).
$XFYHOME/doc/simpleapp/apps/app1_datagrid_chart.xml is the completed XML document application included for your reference.
Downloads | Description | Name | Size | Download method |
|---|
| Simple XML document application and database | simpleapp.zip | 2MB | HTTP |
|---|
| An installation guide | InstallingTheSimpleAppAndData.pdf | 46KB | HTTP |
|---|
More downloads
Resources Learn
Get products and technologies
-
Download a free trial version of DB2 Enterprise 9.
-
Now you can use DB2 for free. Download DB2 Express-C, a no-charge version of DB2 Express Edition for the community that offers the same core data features as DB2 Express Edition and provides a solid base to build and deploy applications.
Discuss
About the authors  | |  | Laura Giddings is a software developer with more than 15 years of experience. She works on database, XML, and Web applications. She is currently focusing on developing technical content for the xfy Enterprise Solutions developers and end user community. |
 | |  | Andy Stewart is a systems engineer for Justsystems working with the xfy product. Previously, he was a developer for five years in Telco C++ and Java. He then moved into
technical sales. He has been involved in application integration
for the last six years, including at the data, application, GUI, and
service layer (such as SOA, application servers, and integration servers). He has
been working with XML for the last two years. |
Rate this page
|  |