Integrating XML with J2EE (
Page 1 of 14 )
In this article, Martin Bond discusses XML and its associated APIs and
standards, and how XML can be used to create flexible structured data that is
inherently portable. This excerpt is from chapter (Day) 16
of Teach Yourself J2EE in 21 Days, second edition, by Martin Bond,
et. al. (Sams, ISBN: 0672325586)
Today, we take a bit of a departure from J2EE
and its emphasis on programming elements to look at what is fast becoming the
lingua franca of the Internet—the Extensible Markup Language (XML).
Throughout the book so far, you have seen many ways in which XML is used
within J2EE applications to describe the structure and layout of the
application. Today and tomorrow, you will study XML and its associated APIs and
standards to gain a fuller understanding of how XML can be used to exchange data
between different components in your applications.
Today, you will learn about
-
How XML has evolved from the need for platform-independent data exchange
-
The relationship between XML and both Standard Generalized Markup Language
(SGML) and Hypertext Markup Language (HTML)
-
How to create well-formed and valid XML documents
-
The Java API for XML Processing (JAXP)
-
How to process XML documents with the Simple API for XML (SAX) and the
Document Object Model (DOM)
-
How XML is used in the J2EE platform
This book is about J2EE, of which XML is just a component. To learn more
about XML, take a look at Sams Teach Yourself XML in 21 Days, which
covers everything you need to know about XML and related standards.
The Drive to Platform-Independent Data Exchange
Applications essentially consist of two parts—functionality described by the
code and the data that is manipulated by the code. The in-memory storage and
management of data is a key part of any programming language and environment.
Within a single application, the programmer is free to decide how the data is
stored and represented. Problems only start when the application must exchange
data with another application.
One solution is to use an intermediary storage medium, such as a database,
and standard tools, such as SQL and JDBC, to gain access to the data in such
databases.
But what if the data is to be exchanged directly between two applications, or
the applications cannot access the same database? In this case, the data must be
encoded in some particular format as it is produced, so that its structure and
contents can be understood when it is consumed. This has often resulted in the
creation of application-specific data formats, such as binary data files
(.dat files) or text-based configuration files (.ini,
.rc, .conf, and so on), in which applications store their
information.
Similarly, when exchanging information between applications, purpose-specific
formats have arisen to address particular needs. Again, these formats can be
text-based, such as HTML for encoding how to display the encapsulated data, or
binary, such as those used for sending remote procedure calls. In either case,
there tends to be a lack of flexibility in the data representation, causing
problems when versions change or when data needs to be exchanged between
disparate applications, frequently from different vendors.
XML was developed to address these issues. Because XML is written in plain
text, and shares similarities with HTML but uses self-describing elements, XML
provides a data encoding format that is
|
This chapter is from Teach Yourself
J2EE in 21 Days, second edition, by Martin Bond et. al. (Sams,
2004, ISBN: 0-672-32558-6). Check it out at your favorite bookstore today. Buy
this book now.
|