Home > AS/400 Tips > WebSphere Strategies for iSeries professionals > WDSC lets you tap into the power of XML
iSeries 400 Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

WEBSPHERE STRATEGIES FOR ISERIES PROFESSIONALS

WDSC lets you tap into the power of XML


Jim Mason, Search400.com expert
06.12.2003
Rating: -4.17- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


When it comes to Web development, XML is a powerful tool. But you don't need to be a highly skilled Java XML developer to make use of it. WebSphere Development Studio Client (WDSC) for iSeries Version 5 (both the Standard and Advanced editions) offers several options to create Web database and XML applications, including a number of helpful wizards.

Although WDSC doesn't build complete, custom XML applications for you, the XML tools go along way to saving time on developing XML applications. It DOES save time by generating a few simple XML applications and many components that you can use and customize relatively easily in your finished application.


[TABLE]

What XML does for Web applications

XML lets you store custom, hierarchical self-describing data in a document using a markup (or tag) language. This is VERY powerful for building applications. Similar to the way an RPG program using an externally described file with DDS can "see" the fields contained in a record format, an XML document has defined elements and attributes that are exposed to your application using an XML parser. With XML, the data structure can be complex data graphs using hierarchical relationships. In addition, XML documents can have associated Document Type Definitions (DTDs) or XML Schemas that further define the related document. Those external definitions can be used to build and validate XML document content.

In the example below, you can see how the markup tags "define" the elements in the XML document.

XML document example generated by WDSC SQL to XML wizard:

The schema below shows a "DDS-like" definition of the XML document above. Schemas provide a more precise definition of an XML document for a parser or application.

XML schema example generated by WDSC SQL to XML wizard:

XML increasingly becomes more important for application development scenarios, especially Web-based applic


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


RELATED CONTENT
Application Development
iSeries calling an .exe
Top 10 programmer tips
Formatted work job scheduler
Convert system date and time
Mixing free format code with embedded SQL
SQL update a field in one file from a field in another file
Webcasts for iSeries programmers
Programming advice from the pros
Easy code copying via the drag and drop method
Setting FTP time-outs

IBM Offerings
Three tips for using WebFacing
WebFacing v5.1.2 may save a lot of money
IBM cuts upgrade prices, launches new entry model in Italy
IBM package aims to capitalize on compliance fears
iSeries deals to keep in mind as you shop
IBM entices iSeries users with price cuts
IBM warns new skills are a must for resellers
What's next for iSeries application developers?
'Twas the Night Before Christmas in IT
The straight dope on choosing iSeries software solutions

iSeries Tools & Utilities
Take control of your iSeries
Vendors announce new products at fall COMMON
The Lazy Coder talks about highlighting your code
How does Sarbanes-Oxley affect you?
Top 10 Administrator Tips
CA Express utility helps you manage SSL certificates
Windows XP SP2 causes problem for iSeries Access
WebFacing v5.1.2 may save a lot of money
Users speak out on lack of iSeries apps
20 FTP tips in 20 minutes

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary


ations. We use XML and related technologies to define and move data from almost any source generator to any target consumer. XML lends itself to easy transformations between a source and target.

The document object model

All of these frameworks provide support for creating, editing, validating and reading XML documents. Generally XML processing is done using streams over a document object model (DOM). The hierarchical document is represented as a set of nodes of different types: simple, complex and collections. The node set can be traversed by an application or parser, usually in sequential order.

In many applications, it's convenient to map the document to a corresponding set of Java beans for processing. Modeling documents as beans, complex types are mapped to Java classes, attributes and end-nodes (leaf nodes) are usually mapped to bean properties, and collections are mapped to array objects or vectors.

An example of mapping the employee document to an Employee bean:

XML tools in WDSC

In addition to the Xerces XML parser and Xalan XSL processor, WDSC offers a reasonably good set of wizards to generate XML artifacts and simple applications. The editors are reasonable for editing the many XML artifacts you have to deal with in building applications: XML documents, XML schemas (.xsd), XML Document Type Definitions (.dtd), XML template files for use with XML database queries (.xst), XSL Extended Stylesheet Language for transforming XML to another format (.xsl), and XPath expressions for selecting nodes within an XML document.

You can even generate code to map XML to DB2 database tables using a wizard that creates a Document Access Definition (DAD). To run this application, you need to buy DB2 XML Extender on the DB2 platform you will run on. The DAD support for DB2 Extender allows complex XML to relational mappings.

IBM was nice enough to provide an affordable option that works with ANY relational database WITHOUT special extender software, a single class: SQLToXML. It is in a jar file (xmltosql.jar) in the WDSC directory tree. You'll need Java skills to use the class. Also, add the Xalan processor and Xerces parser to your classpath because it relies on those XML tools.

Using WDSC XML tools to build a Web application

Let's look at a common application scenario and then review some of the tools WDSC provides to help create our application. One type of application I've built several times involves querying a relational database to generate an XML document and then providing Web access to search and view the document contents. It's useful for applications that generate Web views on relatively static content such as an item catalog. Whenever the catalog changes, the XML catalog document can be regenerated and published to the Web application. The application I built was a Web Employee Phonebook reading an XML document generated from a database.

To build a simple Web XML application that can search, select and view data in an XML document generated from an iSeries DB2 table you'll use WDSC wizards to do the following:

Doing all of that with basic XML tools (parsers, processors etc) is a complex task for a highly skilled Java XML developer. It's much easier to learn how to use the wizards and editors to create the basic components of an application, customize them and link them together in a Java XML Web application. You will need beginner-level Java skills as well as WDSC knowledge to build your application.

An earlier tip on generating a Java Web database application reviewed steps 1, 2 and 6 above in detail. The steps of interest in our XML application are 3, 4 and 5.

For steps 1 and 2, you'll use the database model import fairly often to capture iSeries data definitions in WDSC to build applications. If you are new to SQL, you'll probably want to use the SQL statement builder to build your SQL statements accurately.

Step 3: Generate an SQL to XML database query generating an XML document and schema
The XML tools offer a wizard to generate the XML database query easily: SQL to XML query. Just following the prompts; it's simple to reuse the SQL Select statement you created above to generate an XML document with your data and a corresponding XML schema.

Later, you can use the SQLToXML class to do the same thing dynamically in your Java application code if you need to. IBM provides this class and XMLToSQL to allow your applications dynamic read and write of XML documents to and from any relational database. This is a big plus as you develop more sophisticated applications with dynamic access. The classes are stored in a jar file:

Step 4: Create Java beans that model the XML document using the XML schema
The next step is to generate Java beans that reflect the XML document elements. WDSC provides another wizard to generate the Java beans: Generate Java beans for creating XML instances of an XML schema. The XML schema was created in step 3.

This wizard generates Java beans that use the com.ibm.etools.xmlschema.beans package in the wsdbeans.jar file.

While the generated beans do NOT actually contain your data, they are place holders that can store the XML document data in a bean, as well as routines to load the XML data to the beans and update the XML document from the beans. A useful set of capabilities for a full XML application.

Step 5: Create a client Java Web XML application to search and view the generated Java beans
Here we use WDSC to generate a Java Web XML application based on MVC architecture with a Java servlet and a JSP that uses XSL to generate the output pages in your Web application. The input to this step comes from step 4 -- the Java beans you created. In my case, the Web application allows you to view and maintain employee entries in a phonebook, so I used the EMPLOYEE bean I generated in step 4.

While running the generated application "as is" only gives me the ability to enter a new EMPLOYEE phonebook entry, I can modify the generated application to add access to read the existing XML data and create a selection page in front of the detail view page. To create a select servlet, I'd use the sample Java beans in step 4 that read and write XML document data to the EMPLOYEE Java beans I created.

This process describes using the WDSC XML tools to generate basic components for a Java XML application. You do have to know Java to link all this is into a useful, running application, but you can at least test the individual components in WDSC.

As your Java skills grow, you can modify the generated Web application to do the following:

---------------------------------------

About the author: Jim Mason, president of ebt-now, is an iSeries WebSphere engineer. ebt-now provides iSeries WebSphere, WebFacing project management, engineering, development and training services. For more tutorials, visit www.quickwebsupport.com.

==================================
MORE INFORMATION
==================================


Rate this Tip
To rate tips, you must be a member of Search400.com.
Register now to start rating these tips. Log in if you are already a member.




DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



iSeries Security - Security Tools, Physical Security and System Security
HomeNewsTopicsITKnowledge ExchangeTipsBlogsAsk the ExpertsMultimediaWhite PapersProducts
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 1999 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts