Skip to main content

Integration between XML Forms Generator and Data Studio, Part 2: DB2 pureXML support in XFG

Visualize pureXML into XHTML/XForm for pureXML parameters in Data Web Services, with the support of registered XML Schemas corresponding to pureXML instances

Xiao Feng Zhao (zhaoxfbj@cn.ibm.com), Staff Software Engineer, IBM, Software Group
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, Software Group
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 pureXML® feature of IBM® DB2® 9 has revolutionized support for XML data—handling XML as a new data type that is stored in a natural hierarchy—different from relational data. IBM Data Studio can create Data Web Services with multiple pureXML parameters to manipulate pureXML instances in the database. With the pureXML support in XML Forms Generator (XFG), you can visualize pureXML into an XHTML-based XForm for users. Also, XFG can retrieve the registered related XML Schemas of pureXML instances and generate type information and validation constraints into the target pureXML XHTML/XForm. So pureXML support in XFG makes it easy to build forms interfaces for XML instances stored in pureXML.

View more content in this series

Date:  20 Jan 2009
Level:  Intermediate PDF:  A4 and Letter (706KB | 17 pages)Get Adobe® Reader®
Activity:  4572 views

pureXML and Data Web Services

Gone are the days of storing XML data as a CLOB or shredding to relational tables. The pureXML feature of DB2 9 has revolutionized support for XML data—handling XML as a new data type that is stored in a natural hierarchy—different from relational data. pureXML's seamless integration of XML with relational data speeds application development, improves search performance with highly optimized XML indexes, and is flexible because you can use both SQL and XQuery to query XML data. XML data, stored in pureXML, can be exposed as Web Services through the Data Web Service mechanism. (See Part 1 of this series.)

How pureXML support works in XFG

Frequently used acronyms

  • CLOB: Character Large Object
  • SOAP: Simple Object Access Protocol
  • UI: User interface
  • WSDL: Web Services Description Language
  • XHTML: Extensible Hypertext Markup Language
  • XML: Extensible Markup Language

The first thing we do is to create a mini-pureXML application based on a table defined in DB2 to illustrate the detailed steps of pureXML support in XFG. Table 1 shows the structure of the table. Before the illustration, we insert a sample record as pureXML reference instances in which the XML1 column doesn’t bind to any schema and XML2 column binds to a registered schema—Express schema as seen in Listing 1. Note: A pureXML reference instance is an XML template used to generate the XHTML/XForm with XFG, as we know XFG can generate the form from either XML or WSDL.


Table 1. Overview of the table structure
Sample DB2 table with columns         bound to a registered Express schema and not bound to any schema

Listing 1. Express schema
Express schema

Create Data Web Services

After the table is created in the DB2 database, you use Data Studio to create a SQL file containing the SQL statement:

INSERT INTO XFGDEMO (ID, NAME, XML1, XML2) VALUES (:id, :name, :purexml1, :purexml2)

Then you create the Data Web Services. Please refer to Resources for a description of creating Data Web Services from the SQL file. When you create the Web service sample, generate a WSDL file named insertRecord.wsdl which will look like the file in Listing 2. You can see two pureXML parameters in the generated WSDL file, PUREXML1 and PUREXML1. These two pureXML fields bind to xsd:anyType, and in the following steps you’ll use XFG to visualize them into XHTML/XForm fragments.


Listing 2. pureXML parameters in the WSDL file
pureXML parameters in the WSDL file

Generate the XHTML/XForms

After you create and deploy the Data Web Services from Data Studio, you can use XFG to generate the XHTML/XForms and the corresponding XML files to communicate with the services.

Select the insertRecord.wsdl file, right-click on the WSDL file, and choose the Generate XHTML/XForms wizard from the XForms Generator menu. Figure 1 shows the first wizard step:


Figure 1. First step in the XFG wizard
Configure the generator in the first step in the XFG wizard

Generate validation information

In XFG you can append additional validation constraints to pureXML fields. When you select the Generate validation information option, you then see a validation editor wizard page to configure additional validation rules in the following steps.

Retrieve the pureXML instance from the database

XFG supports two ways to visualize pureXML fields in WSDL. One is to use a pureXML instance in the local file system, and read the binding schema from local file system. The other is to use the pureXML instance in the database and retrieve the registered schema from the XML Schema Repository (XSR). If you select Retrieve PureXML instance from Database checkbox, you can use both options; if you don't select it, you can only use a schema in the file system. Check this box. Click Next.

On the next screen, choose the insertRecord operation and click Next. You then see the Configure PureXML wizard page as in Figure 2. Here, XFG recognizes all of the pureXML parameters. You need to specify the pureXML instances as references in order to generate a visualized XHTML/XForm and then retrieve the pureXML instances from the database. Please note that, of the reference pureXML instances, PUREXML1 doesn’t bind to any schema and PUREXML2 binds to the registered schema as in Listing 1.


Figure 2. Configure PureXML wizard page
The Configure PureXML wizard page

Click Next and the Validation Editor screen shows. Here, you add some validation rules on PUREXML1, which doesn’t bind to any schema.


Figure 3. Validation editor
Validation editor with rules

Continue through the wizard and finally click Finish to generate the XHTML/XForms. The generated XHTML file is insertRecord.xhtml. Figure 4 shows the generated form. (See a larger version of Figure 4):


Figure 4. Generated XHTML/XForm rendered in Firefox
Generated XHTML/XForm rendered in Firefox

Analysis

In the fragments of the generated XHTML form in Listing 3, you see two fieldset tags. Each tag is generated from the specified instance in the database and corresponds to a pureXML parameter in the WSDL file from Listing 2.


Listing 3. pureXML XForm fragments
pureXML XForm fragments

XFG generates bind information, in Listing 4, for the registered schema (you saw the schema in Listing 1).


Listing 4. pureXML bind information generated from the registered schema
pureXML bind information generated from the registered schema

Meanwhile, XFG also generates the bind information in Listing 5 for the PUREXML1 validation rules which you set in the wizard.


Listing 5. pureXML bind information generated from the validation rules
pureXML bind information generated from the validation rules

Multiple model merging for submission

In the generated XHTML/XForm, you'll find three XForm Models:

  • The first model is the global one that corresponds to the WSDL operation insertRecord. This model contains only four elements: ID, NAME, PUREXML1, PUREXML2. The elements map to the four parameter names in Data Web Services.
  • The second and third models are the pureXML models for parameters of PUREXML1 and PUREXML2, retrieved from the database or the local file system. All the data changes of the two pureXML fieldsets in XHTML/XForm applies to these two models.

Before submitting to Data Web Services, XFG will merge these two pureXML models into the first global XForm model using the generated client script in XHTML, as in Listing 6. This script is executed at the client as part of the XHTML form when the form is submitted.


Listing 6. Model merge XHTML script
Model merge XHTML script

The merged data model, in Listing 7, is a complete SOAP message, which the client submits directly to the Web service to insert a new record into the table using the data from the form.


List 7. Merged model
Merged model

Summary

In this article, we briefly described the DB2 pureXML support in XFG. With the pureXML support in XML Forms Generator (XFG), you can visualize pureXML into an XHTML-based XForm for users. In addition, you can rely on XFG to retrieve the registered related XML Schemas of pureXML instances and generate type information. And the validation constraints can be fetched and added into the target pureXML XHTML/XForms. Obviously the pureXML support in XFG makes it easy to build forms interfaces for XML instances stored in pureXML. In this article series, we introduced XForms, XFG, Data Studio, Web services, and the pureXML feature support. Through these two articles, you can easily start to use XFG to generate functional XHTML/XForms UI for the backend Data Services to build a complete data service solution.



Download

DescriptionNameSizeDownload method
Code sample for Listing 1 in articleListing1.zip1KB HTTP

Information about download methods


Resources

Learn

Get products and technologies

  • 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, Web development
ArticleID=364995
ArticleTitle=Integration between XML Forms Generator and Data Studio, Part 2: DB2 pureXML support in XFG
publish-date=01202009
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