Process XML with JavaBeans, Part 1
Interconnect JavaBeans to process XML
By Mark Johnson, JavaWorld.com, 11/20/99
- Digg
- Reddit
- SlashDot
- Stumble
- del.icio.us
- Technorati
- dzone
The expression "eating your own dog food" has gained currency over the last few years. It means taking the product you're
selling in your daily business and using it yourself, so that you understand it from the consumer's point of view. I've been
churning out columns on JavaBeans (my particular brand of dog food) for the last couple of years, teaching readers how to
create new JavaBeans and use them in novel ways. But I
haven't focused on using JavaBeans in applications -- I haven't been eating my own dog food. And it's about time I sat down to a
big chunky bowl of it.
Process XML with JavaBeans: Read the whole series!
With that in mind, this month I am going to cover not how to create JavaBeans, but how to use them. Using JavaBeans to create
applications in an integrated development environment (IDE) is a great way to learn how to think in components. Component
designers and implementers who are forced to chow down on what they've been dishing up quickly learn what makes a component
useful -- or useless. Many developers who assemble JavaBeans into running applications have experience primarily with GUI
components; thus, in this series, I'll particularly focus on components that do data processing and have no runtime user interface.
The software package I'll be using for this discussion is IBM's XML Bean Suite, available for free from IBM's alphaBeans site
(see Resources for a link). This package is very different from the XML JavaBeans and BML I've covered in the past. Those discussions dealt
with converting JavaBean components to XML, or creating JavaBeans from XML. The XML Bean Suite, on the other hand, is a set
of JavaBean components designed for processing XML data. The suite contains JavaBeans that a developer interconnects visually in an IDE in order to read, write, display, search, and filter XML data. Many of these JavaBeans have no user interface at
runtime; they do most of the application's work internally. They're also excellent design examples of how to encapsulate functionality
into a component.
This article assumes that you're familiar with the basics of JavaBeans and XML. Links to background material for this article
appear in the Resources section.
This month's column is mostly an overview of the XML Bean Suite, which contains a large number of classes for processing XML.
I'll also discuss how IDEs interconnect JavaBeans in response to your input, and I'll point out useful design principles as
we go along. Columns to follow will use the XML bean classes to create applications (such as an XML file editor) that process
XML data.
Contents of the XML Bean Suite
The alphaBeans site (see
Resources) is the JavaBeans section of IBM's alphaWorks site, which provides "early adopter developers direct access to IBM's emerging
'alpha-code' technologies." This means that the code is freely downloadable from the site. Some of the code is even available
for free commercial use, but the licensing restrictions vary by package. The designation
alpha also means that the software is not ready for prime time. APIs are not guaranteed to be stable, the software may be updated
erratically, and IBM makes no guarantees about ever turning the material on alphaWorks (and alphaBeans) into commercial products.
Still, several projects that began on alphaWorks have graduated to full commercial status. Most, if not all, alphaWorks technologies
have online discussion forums where users can get advice from the developers creating the software, and can make suggestions
for improving the products.
The XML Bean Suite is a set of 39 Java classes available for free from the alphaBeans site. Since it's alpha software, it
doesn't yet work with the latest version of Swing (it requires Swing 1.0.2), and doesn't even work with the newest version
of IBM's XML processor xml4j (it requires version 1.1.4). The license agreement that appears at download time grants redistribution rights to the code
(though you shouldn't take my word for it -- read the license yourself).
- Digg
- Reddit
- SlashDot
- Stumble
- del.icio.us
- Technorati
- dzone
Resources
Download the source code for this article
XML and XML JavaBeans Suite resources
- For a readable quick-start to XML, try reading my April 1998 JavaWorld feature article, "XML for the absolute beginner"
http://www.javaworld.com/javaworld/jw-04-1999/jw-04-xml.html
- My October 1997 JavaWorld article, "Keep listening for upcoming events," provides a tutorial introduction to the event listener interface concept
http://www.javaworld.com/jw-10-1997/jw-10-beans.html
- There's also an example of event listener interfaces in my September 1997 article on customization, entitled "'Double Shot,
Half Decaf, Skinny Latte' -- Customize your Java"
http://www.javaworld.com/jw-09-1997/jw-09-beans.html
- To download IBM's XML JavaBeans Suite from the alphaWorks alphaBeans site, go to this site and click on the XML Beans link
at the bottom of the list in the leftmost frame
http://www.alphaworks.ibm.com/alphabeans
- IBM's alphaBeans site has a large number of high-quality JavaBeans you can play with
http://www.alphaWorks.ibm.com/alphaBeans
- The parser from IBM's
xml4j package is available free for noncommercial use. It's even free for commercial use, but be sure to read the license agreement
first
http://www.alphaWorks.ibm.com/formula/XML
- The World Wide Web Consortium (W3C) maintains a page covering ongoing efforts in the XML community
http://www.w3.org/XML
- The undisputed mother of all XML news sites is Robin Cover's SGML/XML Web page
http://www.oasis-open.org/cover/
- A good site for XML news, tutorials, and information
http://www.xml.com
- David Megginson, creator of the SAX parser, has a Web site
http://www.megginson.com
- IBM's developerWorks site includes excellent XML resources
http://www.ibm.com/developer/xml
- Microsoft's data management is increasingly based on XML. Read about Microsoft's XML strategies
http://msdn.microsoft.com/xml/default.asp