Skip to main content

Integration between XML Forms Generator and Data Studio, Part 1: Get started with the integration by creating an application

Quickly build an application from database schema to XHTML/XForms using XML Forms Generator and Data Studio

Xiao Feng Zhao (zhaoxfbj@cn.ibm.com), Staff Software Engineer, IBM
Photo of Xiao Feng Zhao
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, Staff Software Engineer, IBM
Qiang Wang photo
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 (malaika@us.ibm.com), Senior Technical Staff Member, IBM
Photo of Susan Malaika
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, Senior Software Engineer, IBM
Keith Wells photo
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.

Summary:  The XML Forms Generator (XFG) provides a jump-start for form development. It can quickly and automatically produce valid and functional forms containing XForms markup embedded within an XHTML document. The input to form generation can be an XML data instance with or without a backing XML Schema, or a WSDL document. Data Web Services, which is based on SQL scripts and Store Procedures, is a database-related application of traditional Web Services. IBM® Data Studio is a client tool for generating Data Web Services visually with the help of a direct connection to the database. The integration between XFG and Data Studio can enable you to generate XForms/XHTMLs from Data Web Services generated by Data Studio. This integration provides advantages such as joining the development of UI pages and Data access seamlessly, reducing the workload of UI development from Data Web Services, and visualizing the pureXML™ UI development with full-support of validation.

View more content in this series

Date:  19 Dec 2008
Level:  Intermediate PDF:  A4 and Letter (502KB | 18 pages)Get Adobe® Reader®
Activity:  4168 views

09 Nov 2009: Corrected misspelled word in text of heading for Figure 6.

XForms and XML Forms Generator

Frequently used acronyms

  • HTML: Hypertext Markup Language
  • HTTP: Hyper Text Transfer Protocol
  • REST: REpresentational State Transfer
  • SOAP: Simple Object Access Protocol
  • UI: User Interface
  • W3C: World Wide Web Consortium
  • WSDL: Web Services Description Language
  • XHTML: Extensible Hypertext Markup Language
  • XML: Extensible Markup Language

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
The architecture and the interactions between XFG and Data Studio

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 NameColumn TypeRequiredDescription
IDINTEGERYRepresents a unique ID for each record inserted into the table.
NAMEVARCHAR(10)YName of each patient.
BIRTHDAYDATEYBirthday of each patient.
HEIGHTDECIMALYHeight of each patient.
WEIGHTDECIMALYWeight of each patient.
DESCRIPTIONVARCHAR(10)YA 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".


Create Data Web Services

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.


Generate the XHTML/XForms

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.

  1. 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
    In the Configure Generator panel, enter a user ID and password to connect to the database.

    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.

  2. Choose an operation for XFG to generate from. Select the insertPatient operation.

    Figure 3. Select a targeted operation
    Select which operation to generate your XForm from

  3. Specify a location for the generated XHTML file.

    Figure 4. Indicate the location for the target file
    Enter or select the folder location for your generated file

  4. 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
    Update the submit target for your output  document

  5. Configure the XML instance creation options as in Figure 6.

    Figure 6. Select the options for your XML instance creation
    Specify the characteristics of your XML instance creation options

  6. Enter or select the location for the XML instance file.

    Figure 7. Specify the XML File Location
    Enter or select the folder location for your XML instance file

  7. Provide the XML schema file location.

    Figure 8. Indicate the location of the Schema file
    Enter or select the folder location of the generated XML Schema file

  8. 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
    XFG-generated XForms model and related 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
View of the sample insertPatient XHTML/XForms in Firefox

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.


Summary

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.


Resources

Learn

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

About the authors

Photo of Xiao Feng Zhao

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 photo

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.

Photo of Susan Malaika

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 photo

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)



Trademarks  |  My developerWorks terms and conditions

Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=XML, Information Management
ArticleID=359899
ArticleTitle=Integration between XML Forms Generator and Data Studio, Part 1: Get started with the integration by creating an application
publish-date=12192008
author1-email=zhaoxfbj@cn.ibm.com
author1-email-cc=dwxed@us.ibm.com
author2-email=wangq@cn.ibm.com
author2-email-cc=dwxed@us.ibm.com
author3-email=malaika@us.ibm.com
author3-email-cc=dwxed@us.ibm.com
author4-email=wellsk@us.ibm.com
author4-email-cc=dwxed@us.ibm.com

My developerWorks community

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere).

My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Rate a product. Write a review.

Special offers