Skip to main content

JiBX 1.2, Part 2: XML schema to Java code

Generate cleaner, customized Java code from XML schema

Dennis Sosnoski, Lead consultant, Sosnoski Software Associates Ltd
Photo of Dennis Sosnoski
Dennis Sosnoski is a consultant and training facilitator specializing in Java-based SOA and Web services. His professional software development experience spans over 30 years, with the last decade focused on server-side XML and Java technologies. Dennis is the lead developer of the open source JiBX XML data binding tool, as well as a committer on the Apache Axis2 Web services framework. He was also one of the expert group members for the JAX-WS 2.0 and JAXB 2.0 specifications. See his Web site for information on his training and consulting services.

Summary:  Code generation from XML schema definitions is widely used for all types of XML data exchange, including Web services. Most data-binding tools rigidly structure generated code based on the schema — even aspects of the schema that may be irrelevant to your application. In this tutorial, second in a two-part series, learn how JiBX 1.2 generates cleaner code by doing a better job of interpreting the schema and eliminating unnecessary class clutter. You'll also see how you can customize the generated code to suit your needs better, including customizations that easily eliminate unnecessary components of the schema.

View more content in this series

Date:  03 Mar 2009
Level:  Intermediate PDF:  A4 and Letter (222 KB | 36 pages)Get Adobe® Reader®

Activity:  2295 views
Comments:  

Before you start

About this tutorial

JiBX is a tool for binding XML data to Java™ objects. JiBX data binding has long been known as the fastest and most flexible approach for binding Java code to XML. But the complexity of its binding definitions and its limited support for increasingly widely used XML schema definitions have frustrated users at times. Fortunately, the 1.2 version of JiBX goes a long way toward eliminating these issues. In this tutorial, you'll learn about using the new features of JiBX 1.2 to generate Java code easily from XML schema definitions and to read and write XML documents matching the generated schema definitions — all without needing to get into the details of JiBX binding definitions. Part 1 covers the flip side of starting from Java code and generating XML schema definitions.

Objectives

This tutorial guides you through the process of using JiBX to generate Java code from XML schema definitions. You'll first learn how to work with a simple schema and generate a default Java data model matching that schema, then use that data model for reading and writing XML documents. You'll next see how customizations can be used to modify the code generation so it better fits your needs. Finally, you'll move on to a more complex industry-standard schema example and explore the power of customizations to simplify the data model generated for that schema and improve usability. After reading this tutorial and working through the supplied examples, you'll be able to use JiBX to generate customized Java data models for your own schemas.


Prerequisites

To understand this tutorial, you should have at least a basic knowledge of both Java code and XML. You don't need a detailed understanding of XML schema definitions, but some familiarity with schema will help you understand the examples better.


System requirements

To run the examples you need to install:

JiBX download and installation instructions are included in the tutorial.

1 of 13 | Next

Comments



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=Java technology, XML, Open source
ArticleID=373423
TutorialTitle=JiBX 1.2, Part 2: XML schema to Java code
publish-date=03032009
author1-email=dms@sosnoski.com
author1-email-cc=

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).

Special offers