Chapter 14. Using XML


14. Using XML

XML, the Extensible Markup Language, is derived from the Standard Generalized Markup Language (SGML). Hypertext Markup Language (HTML) is also a markup language derived from SGML. XML is similar in most ways to HTML, with the exception that, in XML, you can define your own tags. You are not constrained to a predefined set of markup tags as you are in HTML. XHTML is a version of HTML that is XML compliant.

XML is commonly used as a general format for interchanging data across servers and applications. Common uses of XML include in business-to-business processes or storage of complex data such as a word processor document or even graphics files.

XML has gained wide acceptance across all industries and programming languages. Most programming languages now have some support for processing XML data. Java is no different in that respect. Java has excellent support available for processing XML documentsboth creating and reading XML data.

This chapter assumes knowledge of XML. If you want to learn XML or brush up on your XML knowledge, a good book that is tailored to Java development is Java and XML by Brett McLaughlin and Justin Edelson. A new version of this book, the 3rd edition, should be available by the time you read this. The ISBN for this book is 059610149X.

Two common language-independent XML parsing APIs are defined by the World Wide Web Consortium (W3C). These are the DOM and SAX APIs. DOM, which stands for Document Object Model, is a parser that reads an entire XML document and builds a tree of Node objects, which is referred to as the DOM of a document. When using DOM, you end up with a complete parsed representation of the XML document and you can pull pieces of it out at any time. SAX, which stands for Simple API for XML, is not really a parser itself, but instead it is an API that defines an event handling mechanism that can be used to parse XML documents. When using SAX, you supply callback methods that are called by the SAX API when various elements of the XML document are encountered. A SAX implementation scans through an XML document calling the callback methods when it encounters the start and end of the various XML document elements. With SAX, the XML document is never fully stored or represented in memory.

Java's implementation of XML processing is referred to as the Java API for XML Processing, or JAXP. JAXP enables applications to parse and transform XML documents independent of a particular XML processing implementation. JAXP bundles both a DOM and a SAX parser and also includes an XSLT API for transforming XML documents. XSLT stands for Extensible Stylesheet Language Transformations. XSLT technology allows you to transform an XML document from one format into another. JAXP is a standard part of JDK 1.4 and later.




JavaT Phrasebook. Essential Code and Commands
Java Phrasebook
ISBN: 0672329077
EAN: 2147483647
Year: 2004
Pages: 166

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