Introduction
This tutorial is for developers who would like to create a system that allows maximum flexibility in data reporting without complex programming. It discusses the creation of a system that uses XML data binding to create an object that represents the criteria for a report. The object itself can be populated by a user-supplied XML file, making both the criteria and its structure completely flexible.
This tutorial assumes that you are familiar with XML and XML schemas. It also assumes that you are familiar with Java technology, but no GUI programming is required. It also uses a small amount of HTML, but an in-depth understanding of HTML is not crucial.
This tutorial discusses the creation of a data reporting system that uses XML data binding to enable user configuration. The system enables users to change the criteria used to generate a report by altering an XML file. Through the use of a mapping file, the user can even change the structure of the criteria file without having to recompile any of the Java classes that form the basis of the application.
This tutorial covers the following:
- Using a
TreeWalker - Controlling a
TreeWalker's nodes using aNodeFilter - Binding XML data to an object
- Generating an object based on an XML schema
- Choosing nodes using a
NodeFilter - Linking a
NodeFilterto the generated class - Using a mapping file to provide additional flexibility
This tutorial describes the creation of a Java application that provides a report in the form of a servlet. To follow along, you need the following components:
- A Java development environment: At a minimum, you need a JDK such as J2SE 1.3 or above from Sun Microsystems. Version 1.4.2 is available at http://java.sun.com/j2se/1.4.2/download.html.
- The ability to compile and run Java applications: The easiest way to get the additional tools necessary is to use IBM's WebSphere Studio Application Developer (WSAD), which includes not only a development environment, but also a test servlet engine. You can, of course, use a plain text editor and the tools that come with J2SE, but you'll create a lot of additional work for yourself.
- Servlet support: If you are using WSAD, you already have all that you need. If you prefer to use something else, you can download the Tomcat servlet engine from http://jakarta.apache.org/tomcat/index.html.
- XML support: Whether you use WSAD or J2SE 1.3, you need to download an XML parser. This tutorial uses the Xerces parser from the Apache project, which you can download from http://xml.apache.org/xerces2-j/index.html.
- Data binding support: This tutorial uses the Castor XML data binding engine, which you can download at http://www.castor.org/. You can also use the JAXB engine, downloadable from http://java.sun.com/webservices/webservicespack.html, but class names and mappings are different.

