09 Nov 2009: Corrected misspelled word in text of heading for Figure 6.
XForms and XML Forms Generator
The W3C has developed the XForms standard for the presentation and collection of form data. As stated in the W3C Recommendation (see Resources), XForms is intended to be "the next generation of forms for the Web." As the recommendation declares, "By splitting traditional XHTML forms into three parts—XForms model, instance data, and user interface—it separates presentation from content, allows reuse, gives strong typing—reducing the number of round-trips to the server, as well as offering device independence and a reduced need for scripting." XForms documents feature a data model which contains one or more XML instance documents. The form manipulates such an instance document and provides for the submission of that XML to a back-end system.
The XML Forms Generator tooling provides a jump-start for form development. It quickly and automatically produces valid and functional forms containing XForms markup embedded within an XHTML document (we will refer to that combination in this article as "XHTML/XForm"). The input to form generation can be an XML data instance with or without a backing XML Schema, or a WSDL document.
The XML Forms Generator, a plug-in to the open source Eclipse workbench, was first released on alphaWorks in April, 2005. See Resources for links to the Eclipse Workbench download site and to the alphaWorks page for the XML Forms Generator, where you can learn about, download, and install the tooling.
Data Studio and Data Web Services
IBM Data Studio is an Integrated Data Management Environment. It provides a complete development and testing environment for building database objects, queries, database logic, and pureQuery applications. With Data Studio tooling, you can develop database applications faster with the integrated query editor for SQL and XQuery, optimize applications and queries with ease, build and test stored procedures (in Java™ code and SQL) with the interactive routine debugger, and rapidly develop or customize the SQL inside Java applications.
The IBM Data Studio solution includes many new features, among these is the Data Web Services support. Data Web Services is the next-generation Web service provider for IBM database servers. Data Web Services provides a full Web service interface that supports REST-style services (HTTP GET/POST binding), SOAP over HTTP Web services, and automatic WSDL generation. Data Web Services supports the IBM DB2® family of databases, IBM Informix® Dynamic Server (IDS), and many popular Web servers, such as Apache Tomcat v5.5, IBM WebSphere® Application Server V6.1, and IBM WebSphere Application Server Community Edition V1.1. You can learn more about how to use Data Studio to create Data Web Services from the published developerWorks article (see Resources).
Why integrate XFG into Data Studio
Data Studio can greatly facilitate the Data Web Services development at the database and middleware layers while XFG can improve the efficiency of XForms-based UI development by generation from WSDL files. So we integrate XFG into Data Studio to offer an automatic and fast development process across the database, Web services, and an XForms-based UI to create a holistic solution that uses the features of Data Studio and XFG.
The obvious values brought by the integration between XFG and Data Studio are:
- XFG is a rapid prototyping tool and XML Message visualizer for database projects in Data Studio.
- XFG is a complement to Data Studio for rapid UI development.
- XFG can visualize DB2 pureXML data into XHTML/XForms.
- XFG generates validation information from database metadata and XML Schema.
- The integration can reduce the development workload and improve the user experience to a large extent.
XFG and Data Studio are both Eclipse plug-ins, which makes it easier to integrate. To easily integrate XFG with Data Studio, download the XFG plugins from the update site and install them on Eclipse (see Resources for XML Forms Generator.)
How XFG and Data Studio work together
This section introduces how XFG and Data Studio work together to create web applications. Figure 1 shows the architecture and the interactions between XFG and Data Studio.
Figure 1. Diagram of Data Studio and XFG architecture and interactions

In the interaction flow, Data Studio generates Data Web Services from database metadata. Then XFG utilizes Data Web Services and database metadata to generate XHTML/XForms. Finally, the generated XHTML/XForm communicates with Data Web Services through REST/SOAP.
To illustrate the detailed steps of how Data Studio and XFG work together, you will create a mini-patient information management application based on the structure in the table below.
| Column Name | Column Type | Required | Description |
|---|---|---|---|
| ID | INTEGER | Y | Represents a unique ID for each record inserted into the table. |
| NAME | VARCHAR(10) | Y | Name of each patient. |
| BIRTHDAY | DATE | Y | Birthday of each patient. |
| HEIGHT | DECIMAL | Y | Height of each patient. |
| WEIGHT | DECIMAL | Y | Weight of each patient. |
| DESCRIPTION | VARCHAR(10) | Y | A short description of each patient. |
To try this example, download DB2 Express-C for free (see Resources for the download site). Use the DB2 Control Center to create a database, and then create the table to match the description in Figure 2. In this case, we created a table named "PATIENT" using the schema "DB2ADMIN".
After the table was created in DB2, we used Data Studio to create the Data Web Services. To do this, Data Studio uses SQL that you create to define the web service (either a single SQL statement, as we did, or a stored procedure). Using an SQL statement, all the parameters will be mapped to input parameters in the WSDL of the Data Web Services. Both Data Studio and XFG support two parameter styles: unnamed parameters and named parameters.
If you use unnamed parameters, your SQL statement looks something like this:
INSERT INTO DB2ADMIN.PATIENT (NAME, BIRTHDAY, HEIGHT, WEIGHT, DESCRIPTION) VALUES (?,?,?,?,?)
Notice the that the values are represented by variable placeholders (?,?,?,?,?).
If you use named parameters, your SQL statement might look like this, with a list of named variables holding the values to be inserted:
INSERT INTO DB2ADMIN.PATIENT (NAME, BIRTHDAY, HEIGHT, WEIGHT, DESCRIPTION) VALUES (:NAME, :BIRTHDAY, :HEIGHT, :WEIGHT, :DESCRIPTION)
With named parameters, each label in the generated XHTML/XForm will be the same as its corresponding parameter name; with unnamed parameters, each label will be assigned a name such as p1, p2, and so on. We do not describe this whole process here. To see how to create Data Web Services from the SQL file, refer to Resources. In our sample we created a SQL file named insertPatient.sql, then created the corresponding service and generated a WSDL file named insertPatient.wsdl.
After you create and deploy the services from Data Studio, you can use XFG to generate the XHTML/XForm and the corresponding XML files to communicate with the service.
- Using XFG, select the insertPatient.wsdl file, right-click on the WSDL file,
and choose the Generate XHTML/XForms wizard from the XForms Generator menu item.
Figure 2 shows the first wizard step:
Figure 2. The first step using the XFG wizard
This step requires a username and a password for the connection to the underlying database. As for the two options, "Generate validation information" and "Retrieve PureXML instance from Database", they are both used with pureXML support in DB2 and we'll discuss that in the second article in this series; for now, leave the check boxes unchecked.
- Choose an operation for XFG to generate from. Select the insertPatient operation.
Figure 3. Select a targeted operation
- Specify a location for the generated XHTML file.
Figure 4. Indicate the location for the target file
- Change the submit target highlighted in Figure 5 to the endpoint of the
deployed Web service. The generated XHTML/XForm can communicate with the Web
service only if you set the endpoint (refer to the dotted rectangle) correctly.
Figure 5. Customize the output document
- Configure the XML instance creation options as in Figure 6.
Figure 6. Select the options for your XML instance creation
- Enter or select the location for the XML instance file.
Figure 7. Specify the XML File Location
- Provide the XML schema file location.
Figure 8. Indicate the location of the Schema file
- Finally, click Finish to generate the XHTML/XForm. The generated XHTML file
is named insertPatient.xhtml.
In insertPatient.xhtml, XFG generated an XForms model and related bind attributes as you can see in Listing 1 (see a larger version of Listing 1). In the XForms model, XFG generated data constraints as XForms bind attributes which correspond to database metadata, such as column type, length, required, and so on.
Listing 1. Generated XForms model and bind attributes
When you view insertPatient.xhtml in Firefox, you see the screen as in Figure 9 (see a larger version of Figure 9):
Figure 9. View of insertPatient XHTML/XForms in the Firefox browser

From the rendered view of insertPatient.xhtml, we can see that:
- All the required fields are followed by a red asterisk. All of the fields are required except for the DESCRIPTION field.
- If an incorrect value is entered, the label will become red to alert the user of a validation error. As seen in Figure 5, "HEIGHT" is a decimal but we entered a string value. (If you are viewing this in color, you can see that the label is red.)
- Every field in the form has a hint message. As you can see, "HEIGHT is (decimal, REQUIRED)" is shown.
- For fields whose types are Date, Boolean or other fields that can be virtualized by special widgets, the corresponding widget will show in the value field when you edit the value. For example, a Date Picker is displayed for a Date type, and a CheckBox for a Boolean type.
Using insertPatient.xhtml, you can communicate with the Web service by submitting the form. The Web service will invoke the SQL INSERT statement you saw earlier, using the values from the form to insert a row into the table. You can go to the back-end database table to check the contents; you will find a corresponding record has been successfully added to the table.
In this article, we briefly described XForms, XForms Generator, Data Studio, and Data Web Services, and then we talked about the reason to integrate XFG with Data Studio. We illustrated how XFG can work with Data Studio to provide the end user a seamless approach for building a complete data service solution. In the second article of this series, we will outline the DB2 pureXML support in XFG. We will cover how to visualize pureXML instances into XHTML/XForms through the integration of XFG with Data Studio, with the support of registered XML Schemas corresponding to pureXML instances.
Learn
- Integrate between XML Forms Generator and Data Studio, Part 2: DB2 pureXML support in XFG(Xiao Feng Zhao, Qiang Wang, Susan Malaika, Keith Wells; developerWorks; December 2008): In Part 2 of this series, create an XForm app using the XML Forms Generator in Data Studio. You can retrieve the XML schema, generate type information, and define constraints to create the form, and then insert the form data into DB2 using Data Web Services.
- W3C Recommendation for XForms:Combine the ability to separate purpose, presentation, and results with XML in this foundation for Web-based forms.
- Data Web Services: Build Web services the new way to access IBM database servers: Service-enabling your access to DB2 and Informix Dynamic Server(Vijay Bommireddipalli, developerWorks, December 2007): In this overview of Data Web Services, learn to build a Data Web Service and generate Web services-based access to your database.
- The DB2 XML wiki: Find papers, presentations, and demonstrations related to DB2 9 and pureXML. The authors recommend the DB2 Demo program (George Baklarz, developerWorks, updated February 2008) as a starting point.
- XML Forms Generator/Data Studio Overview (alphaWorks, November 2008): Generate forms that conform to the XForms 1.0 standard with this Eclipse plug-in.
- XForms tutorial (W3 Schools): Learn to use XForms, the next generation of HTML forms, in your applications.
- Web services on developerWorks: Get the resources you need to advance your skills in the SOA and Web services area.
- Information Management on developerWorks Visit and find resources for learning how you can use SOA and Web services with IBM Information Management products.
- Eclipse.org: Visit the Eclipse site. The projects of this open source community focus on building an open development platform comprised of extensible frameworks, tools, and runtimes for building, deploying and managing software across the lifecycle.
- IBM XML certification: Find out how you can become an IBM-Certified Developer in XML and related technologies.
- XML technical library: See the developerWorks XML Zone for a wide range of technical articles and tips, tutorials, standards, and IBM Redbooks.
- developerWorks technical events and webcasts: Stay current with technology in these sessions.
- The technology bookstore: Browse for books on these and other technical topics.
- developerWorks
podcasts: Listen to interesting interviews and discussions for software developers.
Get products and technologies
- Web Tools Platform (WTP) Project: Get the Eclipse Web Tools Platform (WTP) project and extend the Eclipse platform with tools for developing Web and Java EE applications. It includes source and graphical editors for a variety of languages, wizards and built-in applications to simplify development, and tools and APIs to support deploying, running, and testing apps.
- DB2 Express-C: Download a free trial version of the DB2 Express 9 database server.
- DB2 for Linux™, UNIX™, and Windows.: Download a free trial version of an interactive data server that merges the high performance and ease of use of DB2 with the self-describing benefits of XML.
- XML Forms Generator/Data Studio on
alphaWorks: Download the standards-based, data-driven Eclipse plug-in that generates functional forms with XForms mark-up embedded within an XHTML document from a XML data instance or a WSDL document.
- IBM Data Studio: Download a free trial version of an integrated database development environment that speeds application design, development, and deployment as it increases data access efficiency and performance.
- IBM trial software for product evaluation: Build your next project with trial software available for download directly from developerWorks, including application development tools and middleware products from DB2®, Lotus®, Rational®, Tivoli®, and WebSphere®.
Discuss
- Participate in the discussion forum.
- Data Studio Team
blog: Check out this blog and get involved in the Data Studio Space.
- XML zone discussion forums: Participate in any of several XML-related discussions.
- developerWorks blogs: Check out these blogs and get involved in the developerWorks community.

Xiao Feng Zhao is a staff software engineer in the China Emerging Technology Institute, China Software Development Laboratory. He concentrates on IBM Incubator projects. His interests include Web 2.0, SOA, J2EE, and Web technologies. He is currently working on PoCs development for Ajax and SOA standards.

Qiang Wang works as a technical leader in the China Emerging Technology Institute, China Software Development Laboratory. He concentrates on IBM Incubator projects and SOA-related topics. His interests include J2EE, SOA, MDA/MDD, AOP, RUP, and project management. He is currently leading some industry related SOA solutions.

Susan Malaika is a Senior Technical Staff Member in the IBM Information Management Group (part of IBM Software Group). Her specialties include XML, the Web, and databases. She has developed standards that support data for grid environments at the Global Grid Forum. In addition to working as an IBM product software developer, she has also worked as an Internet specialist, a data analyst, and an application designer and developer. She has also co-authored a book on the Web and published articles on transaction processing and XML. She is a member of the IBM Academy of Technology.

Keith Wells is a software engineer at IBM in Research Triangle Park, N.C. Mr. Wells has been involved with Emerging Technologies and the Emerging Technologies Toolkit for several years. Currently, he is exploring opportunities with compound documents, model-driven development, software standards, and XML-based technologies.
Comments (Undergoing maintenance)





