Skip to main content

If you don't have an IBM ID and password, register here.

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. This profile includes the first name, last name, and display name you identified when you registered with developerWorks. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

XML and Java technology: What's XML really good for?

XML as a data interchange format... and not much else

Brett D. McLaughlin, Sr., Author and Editor, O'Reilly Media, Inc.
Photo of Brett McLaughlin
Brett McLaughlin has worked in computers since the Logo days. (Remember the little triangle?) In recent years, he's become one of the most well-known authors and programmers in the Java and XML communities. He's worked for Nextel Communications, implementing complex enterprise systems; at Lutris Technologies, actually writing application servers; and most recently at O'Reilly Media, Inc., where he continues to write and edit books that matter. Brett's upcoming book, Head Rush Ajax, brings the award-winning and innovative Head First approach to Ajax. His last book, Java 1.5 Tiger: A Developer's Notebook, was the first book available on the newest version of Java technology. And his classic Java and XML remains one of the definitive works on using XML technologies in the Java language.

Summary:  It's no secret that XML continues to be one of the most popular technologies that's shown up in the last ten years. But what is XML really good for? Is it useful for configuration data? For data exchange? As a medium for data storage? What is XML really good for? This article offers food for thought and encourages you to share your thoughts on the subject.

View more content in this series

Date:  20 Feb 2007
Level:  Introductory

Comments:  

Settling into XML

With XML no longer a new technology, most people have a good idea about how it works, and how they like to use it. However, the jury is still out on XML's "killer application" -- the ultimate usage of the data format that seems to justify its creation. As you look at some of the most common usages in this article, you'll quickly see that even experts disagree, and XML can be used -- or not used -- in lots of different applications.


XML for configuration data

One of the earliest uses of XML, and still one of the most popular, is using XML as a data format to store configuration data. Almost as soon as XML became popular, programmers began to replace their proprietary configuration files with XML. Properties files, text files with name-value pairs, comma-separated values, proprietary data formats -- all were tossed out in favor of XML documents, complete with tags, elements, attributes, and textual data.

A verbose data format

The most obvious problem with this application of XML is that by definition, XML is a very verbose data format. In other words, it takes a lot of space to say anything in XML. For instance, here's a simple name-value pair file fragment:

firstName=Brett
lastName=McLaughlin
email=brett@newInstance.com

Compare this with essentially the same data in XML:

<?xml version="1.0"?>
<config-data>
 <firstName>Brett</firstName>
 <lastName>McLaughlin</lastName>
 <email>brett@newInstance.com</email>
</config-data>

There are a lot of extra characters introduced for the "convenience" of XML. That means that you traded speed (it always takes less time to read less characters) for the XML technology choice.

XML processing APIs

In addition to the extra characters that it usually takes to represent data in XML as opposed to other text formats, you will need some software to process and read the XML. While you could write an XML parser, you'd almost certainly want to use one of the many XML parsers already available, on a variety of platforms. So you'll probably need to add a library or two to your software's resources, and learn to use those APIs.

While it's never bad to learn new APIs, realize that you probably will replace working code that reads in your existing textual configuration data with new code that you'll have to write yourself, using additional libraries that you'll have to make available in your application. In other words, you're replacing working code with new code and additional dependencies, both at compile-time and run-time (assuming you're working in a compiled language, but you get the idea).

The cost of flexibility

The question then becomes one of cost versus value. The cost of using XML for configuration data is fairly high; I just mentioned verbosity and resource requirements, but there are plenty of other negatives. The major positive -- assuming you realize that being the cool guy that knows how to use XML really isn't much of a positive -- is flexibility. If you already use XML, or have multiple applications, potentially in multiple languages, that all share configuration data, then XML might be a very viable strategy for configuration data.

With that exception, though, what do you really gain by using XML as the format for your configuration data? I think there are a couple of other good reasons, but I'm not telling -- I'd like to hear from you. Check out the Resources section, click on XML and Java technology forum, and let me know. I'm curious to hear what advantages you think XML provides for configuration data.


XML for transferring data

Beyond configuration data, XML has become a popular option to send data between components or layers of an application. In this model, different pieces of an application communicate in the "language" of XML. While this is a little more technically challenging than simply using XML for configuration data, it's nearly as popular, and underlies technologies like SOAP, data binding, and Web services.

Intra-application data transfer

One of the most common uses of XML as a data format is to send information between different parts of the same application. This is pretty easy to put into place because the same programmer, or programmer teams, control both the sending and receiving end of the data. Unfortunately, this is also almost certainly the worst use of XML for transferring data.

When you send and receive data in the same application, you add the same overhead as discussed in the section on configuration data to your application: verbosity, larger files, and the need for an XML parser library (at a minimum).Rarely do you actually gain much from using XML, as well. In most cases, a much better solution is to send serialized data or objects native to the programming language that you use. It's usually faster, because it takes less bandwidth to transfer the data, and easier to decode on the receiving end.

Inter-application data transfer

A much better use for XML in this general area is to send data from one application to another using XML as the data transfer format. You have one component, say in your application, that sends data to another component, in a business partner's application. The data is encoded as XML.

This has some real advantages, because you don't have to know the programming language of the other application, or anything about how the data will be used. The same is true in reverse; if you receive the data, you have to know very little about the sending application. In this case, the negative effect of the verbosity of XML is probably outweighed by the flexibility you pick up, and by having to code only to the XML data format, rather than another company's programming specifics or technology choices.

Variation on a theme: Web services

Web services, SOAP, WSDL, and the variety of other buzzwords that are hot right now justify their own coverage. However, the varieties of Web services available are really just a subset of inter-application data transfer. You send (or receive) data from another application's components, provided by some other business or technology provider.

The only substantial difference is that Web services typically require you to use XML. So the choice isn't really whether or not you want to use XML when it comes to Web services; it's whether you want to use Web services at all. And that becomes a much bigger issue: You weigh the value of using the features of the Web services versus the cons of dealing with that provider, the speed of the provider (which has something to do with XML, but is probably also affected by bandwidth, latency, the specific provider, and a host of other factors), and the reputation of the company. In other words, XML becomes a negligible factor, not a controlling one.


In conclusion

While most articles present concrete solutions to specific problems, this article is meant to get you thinking. In most potential applications of XML, there's simply no "right" answer. Sometimes XML seems a better choice than alternatives, sometimes it's almost certainly not a good choice, but in many cases, it's just one option among many. Your job is to think critically about the general applications detailed here, and then try and make some application to the specific problems that you run across in your own business and projects.

I also encourage you to jump online and check out the various XML forums (see the Resources section for links), and continue this discussion. I'll hang around the XML and Java technology forum, hoping to spur on interesting conversation and debate. So do some thinking, and then hop on a developerWorks forum and speak up. See you online.


Resources

About the author

Photo of Brett McLaughlin

Brett McLaughlin has worked in computers since the Logo days. (Remember the little triangle?) In recent years, he's become one of the most well-known authors and programmers in the Java and XML communities. He's worked for Nextel Communications, implementing complex enterprise systems; at Lutris Technologies, actually writing application servers; and most recently at O'Reilly Media, Inc., where he continues to write and edit books that matter. Brett's upcoming book, Head Rush Ajax, brings the award-winning and innovative Head First approach to Ajax. His last book, Java 1.5 Tiger: A Developer's Notebook, was the first book available on the newest version of Java technology. And his classic Java and XML remains one of the definitive works on using XML technologies in the Java language.

Report abuse help

Report abuse

Thank you. This entry has been flagged for moderator attention.


Report abuse help

Report abuse

Report abuse submission failed. Please try again later.


developerWorks: Sign in

If you don't have an IBM ID and password, register here.


Forgot your IBM ID?


Forgot your password?
Change your password


By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. This profile includes the first name, last name, and display name you identified when you registered with developerWorks. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

Choose your display name

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

(Must be between 3 – 31 characters.)


By clicking Submit, you agree to the developerWorks terms of use.

 


Rate this article

Comments

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, Java technology
ArticleID=196641
ArticleTitle=XML and Java technology: What's XML really good for?
publish-date=02202007
author1-email=brett@newInstance.com
author1-email-cc=dwxed@us.ibm.com

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.

For articles in technology zones (such as Java technology, Linux, Open source, XML), Popular tags shows the top tags for all technology zones. For articles in product zones (such as Info Mgmt, Rational, WebSphere), Popular tags shows the top tags for just that product zone.

For articles in technology zones (such as Java technology, Linux, Open source, XML), My tags shows your tags for all technology zones. For articles in product zones (such as Info Mgmt, Rational, WebSphere), My tags shows your tags for just that product zone.

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