Chapter 7. Java and XML


Extensible Markup Language (XML ) has become an essential technology for enterprise applications. The XML specification[*] allows users to define unique and structured document formats, allowing for easy and flexible data exchange between applications. Since the syntax of an XML document is bound by a public specification, XML documents can be read and manipulated by a wide variety of tools. Because XML documents are text-based, they can be easily transmitted between different systems using a number of transportation mechanisms, from JMS to HTTP.

[*] The complete specification, developed by the World Wide Web Consortium , is available from the W3C web site at http://www.w3.org/XML. The site also includes a variety of related specifications and other useful resources.

XML documents can be freely structured, although they must abide by a basic set of XML rules that define a well-formed document. More commonly, however, the document structure is further defined by a Document Type Definition (DTD). With a standardized DTD, enterprise applications can exchange data without knowledge of each other's native formats. Industry working groups have defined DTDs for everything from bank transactions to medical records to electronic books. DTDs are very common, although they have been partially supplanted by XML Schemas, a more sophisticated way of describing the structure of an XML document that, among other things, supports defining data types.

The advantages of combining Java and XML are obviousa cross-platform language and a cross-platform data specification. We don't have space here to discuss XML itself in depthfor more information, try Learning XML by Erik T. Ray (O'Reilly). This book covers the XML specification itself, including topics such as XML namespaces, DTDs, the XLink and XPointer specifications for rich links, and the XSLT transformation specification (which we will touch on later in this chapter). We have tried to include enough information to give newcomers a taste of what can be done.

In this chapter, we're going to take a quick look at Sun's Java API for XML Processing (JAXP ) Version 1.2, which provides a standardized approach to processing XML files in Java. JAXP is included in Version 1.4 of the J2EE specification. While originally an enterprise API, JAXP joined the standard J2SE distribution with J2SE 1.4. JAXP includes three other specifications by reference: the Simple API for XML parsing (SAX), Version 2; the W3C's Document Object Model (DOM ), Level 2; and the XSLT (XML Stylesheet Transformation) specification. We also discuss using JAXP to access DOM and SAX parsers and XSLT processors and offer a quick introduction to using DOM and SAX. If you want to know more about using Java with XML, try Brett McLaughlin's Java and XML (O'Reilly).



Java Enterprise in a Nutshell
Java Enterprise in a Nutshell (In a Nutshell (OReilly))
ISBN: 0596101422
EAN: 2147483647
Year: 2004
Pages: 269

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net