Some reader favorites:
EJB fundamentals and session beans
Create a scrollable virtual desktop in Swing
Wizard API updated!
Tim Boudreau has released a new version of the Swing Wizard library (version 0.997) that fixes the WizardException bug reported in JavaWorld's recent Open Source Java Project profile. The article's examples have been reworked to test out the new, improved WizardException. Thanks, Tim, for this helpful fix!
Open Source Java Projects: The Wizard API
The Java Architecture for XML Binding provides a powerful and practical way of working with XML content from within Java applications. The newly released JAXB 2.0 offers many new features, including full support of all XML Schema features, significantly fewer generated classes, generated classes that are easier to manipulate, and a more flexible validation mechanism.
To understand how to process XML documents in Java with JAXB 2.0, we need to look at the two main JAXB components:
The JAXB binding compiler (or xbj) lets you generate Java classes from a given XML schema. The JAXB binding compiler transforms an XML schema into a collection
of Java classes that match the structure described in the XML schema. These classes are annotated with special JAXB annotations,
which provide the runtime framework with the mappings it needs to process the corresponding XML documents.
The binding runtime framework provides an efficient and easy-to-use mechanism for unmarshalling (or reading) and marshalling (or writing) XML documents. It lets you transform an XML document into a hierarchy of Java objects (unmarshalling) or, inversely, transform a Java object hierarchy into XML format (marshalling). The term marshalling traditionally refers to disposing troops in some suitable manner. In networking, it refers to placing data items into a buffer before sending them over a communication channel.
Combined, these two components produce a technology that lets Java developers easily manipulate XML data in the form of Java objects, without having to know the nitty-gritty details of the Simple API for XML Processing (SAX) or the Document Object Model (DOM), or even the subtleties of XML Schema.
To get started with JAXB 2.0 you need:
This article was written using the GlassFish JAXB reference implementation release candidate.
The JAXB compiler binds an XML schema to a set of Java classes. An XML schema is an XML document that describes, very precisely, the elements and attributes authorized in a certain type of XML document. In this example, we use a training course booking system that can accept orders in XML format. A typical order looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<booking xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<company name="ACME Consulting">
<address>10 Coyote Avenue, Arizona, USA</address>
<contact name="Duke" email="duke@acme.com" telephone="1234567890"/>
</company>
<student firstName="Jane" surname="Dow"/>
<student firstName="John" surname="Doe"/>
</booking>
The corresponding XML schema describes how the training course is booked, and contains details of the booked course, the enrolled
students, the company making the booking, and so forth. An XML schema description is extremely rigorous and can include details
such as the number of elements allowed in a list of objects (cardinality), optional and mandatory attributes, and more. The
schema for the training course bookings (called course-booking.xsd) is shown here:
| Subject | Replies |
Last post
|
|
By Nandan |
0 |
04/25/07 04:48 AM
by Nandan |
|
By JSS |
2 |
10/29/06 08:30 AM
by Anonymous |
|
By JavaWorld
|
0 |
10/05/06 08:31 AM
by JavaWorld |
Free Download - 5 Minute Product Review. When slow equals Off: Manage the complexity of Web applications - Symphoniq
![]()
Free Download - 5 Minute Product Review. Realize the benefits of real user monitoring in less than an hour. - Symphoniq