Web Developer's Journal: XML By Example [Book Review]Mar 22, 2000, 23:42 (1 Talkback[s])
(Other stories by Hans C. Arents)
WEBINAR: On-demand webcast
How to Boost Database Development Productivity on Linux, Docker, and Kubernetes with Microsoft SQL Server 2017 REGISTER >
By Hans C. Arents, Web Developer's Journal
XML (EXtensible Markup Language) is widely seen as the key enabling technology for the next phase in the evolution of the Internet. All the new breakthrough Internet technologies such as business-to-business e-commerce data exchange (BizTalk) or wireless Web access from digital mobile phones (WAP) are based on the use of XML. As a result there is a lot of excitement and hype surrounding XML, leading to an avalanche of good (and not-so-good) XML books.
These XML books range from excellent introductory books like XML: A Primer or Teach Yourself XML in 21 Days to essential reference works like the XML Bible or Professional XML. The recently released XML by Example by Benoît Marchal sits somewhere in the middle, providing you with just the right amount of information to get you immediately started developing XML solutions, but still offering you enough background information to see the big picture behind XML and its related standards.
A Useful Focus On Practical XML
Most XML books seem to suffer from the same shortcoming: they're full of dry theory on XML and its related standards, but they're lacking in clear, practical examples on precisely how to use this exciting technology. The by Example series of books by Que has always advocated taking a hands-on approach, by not just talking about concepts, but also offering the developer working examples of those concepts in real use. XML is full of very powerful, but also pretty abstract concepts, so it is certainly necessary to illustrate the power of XML by working code that a developer can try to understand and immediately use.
The first four chapters provide a gentle introduction to XML. In contrast to most books on XML, not too much time is spent on discussing XML's roots in SGML (Standard Generalized Markup Language), but Marchal still makes very clear the defining characteristics of XML, inherited from XML: its focus on separating content from structure and presentation, the importance it attaches to syntactical correctness and structural validation, the attention it devotes to truly capturing the meaning and purpose of data, etc.
From the very beginning, the author correctly argues that XML is not only well suited for document applications but also for data applications, since XML basically makes the distinction between documents and data irrelevant. Both become information that can now be exploited as well by humans as by programs. The first chapter also provides a whirlwind overview of the whole alphabet soup of XML related standards (XML Namespaces, XML Schemas, XSL, XLink and XPointer, DOM and SAX), and briefly discusses the different categories of XML processing software (browsers, editors, parsers and convertors, for a complete overview see XMLsoftware).
The second chapter delves right into the hart of the matter, discussing the syntax of XML, starting with some simple examples, highlighting common errors and pitfalls and ending with some frequently asked questions on XML syntax. For a more comprehensive syntax overview you may also want to consider buying the XML Pocket Reference by Robert Eckstein, which serves as handy companion when you're writing code, or the second edition of The XML Companion by Neil Bradley.
The third chapter teaches how to model XML documents and data using DTDs (Document Type Definitions), and also discusses how the W3C is now working on XML Schemas as an alternative to DTDs (in order to address a DTD's major shortcomings when it comes to modeling data). This chapter is clearly the most abstract one in the whole book, but since DTDs are such an essential part of what makes XML perform its magic, you'll have to get through it one way or another.
Fortunately, Marchal succeeds in clearly illustrating each key DTD concept by offering some well-choosen examples. If after reading this chapter you suddenly can't get enough of DTDs, I suggest you study them in-depth by reading the excellent Inside XML DTDs by Simon St. Laurent, et al., which discusses in great detail a number of important industry-standard DTDs. The fourth chapter discusses how XML namespaces (basically a way of uniquely prefixing XML tags so that one can avoid name clashes) help to manage XML extensibility.
After these first 125 pages of pretty dry (but nonetheless essential) stuff we finally get down to business in chapters 5 and 6, where Marchal explains how you can manipulate and display XML documents using XSL (XML Stylesheet Language). Marchal makes it very clear that XSL actually consists of two components, XSL Transformations (XSLT) and XSL Formatting Objects (XSLFO), and that XSL is indeed not only important as a formatting language (allowing you to style XML documents for display in a Web browser or on paper), but even more important as a transformation language (allowing you to transform an XML document into HTML or any other type of XML document).
Chapter 5 discusses these transformation capabilities of XSL in great detail, while chapter 6 more briefly discusses the formatting capabilities of XSL, focussing on the use of CSS (Cascading Style Sheets, well-known from the HTML world) to display nicely formatted XML documents in Microsoft's Internet Explorer 5.x or Mozilla's Gecko (the future Netscape 5.0). Marchal has to limit himself to a discussion of CSS since XSL Formatting Objects are still in the draft stage, and little or no XML tools actually support them. This "let's stick to what actually works" attitude typifies the whole book and is a refreshing difference with other XML books such as The XML Handbook by Paul Prescod, which tend to devote too much time to XML stuff "that should work" (but doesn't since the corresponding standard is still in a state of flux).
In chapter 8, he discusses the differences with SAX (Simple API for XML), an event-based Java API for addressing XML data, by building the same application using this second standard API. The code given for these two applications is very insightful, not just because it clearly illustrates the different parsing models behind DOM and SAX, but also because it contains clean, object-oriented code for elegantly encapsulating the lower-level API calls of DOM and SAX.
In the 9th chapter, the focus is no longer on reading and parsing XML documents, but on writing XML documents. Marchal shows how using the DOM is ideal when modifying existing XML documents, but also clearly shows how using your own code to write XML is far more efficient when you are simply generating new XML documents.
These chapters 7, 8 and 9, combined with the previous chapters 5 and 6, form the real meat of the book, and it's here that you get your money's worth: not simply concepts, but actual working code that really does something useful. It's a pity the book doesn't contain a CD-ROM with all the sample code, but you can go to the by Example Web site for all code examples and additional material associated with the book.
Putting It All Together
The final chapters 10, 11 and 12 nicely round off the book, by reviewing some of the fundamental XML concepts you've learned in the previous chapters and illustrating their use in a working e-commerce application. Chapter 10 discusses the importance of using the inherent flexibility of XML correctly, by finding the right level of abstraction that will allow your applications to use XML document/data formats in the most effective way. You will find some basic practical guidelines here, but for more in-depth treatment of the same subject you should also consider reading Structuring XML Documents by David Megginson.
Chapter 11 sets the stage for the development of the e-commerce application, by discussing the basic concepts behind 3-tier and n-tier applications, highlighting how XML can be used at both the client, the middle and the server tier. For those of you who still think that XML only has a role to play in the Web browser (the client tier), this chapter is a real eye-opener that will get you thinking about XML in completely new ways.
The final chapter discusses the commented source code for the XCommerce application, a multi-merchant Web mall making extensive use of XML and some basic Java. XCommerce is a small but realistic 3-tier e-commerce application, illustrating the use of XML and XSL in the Web browser, Java servlets for forms handling in the middle tier, and JDBC for data access in the server tier. This sample application is certainly more interesting than the rather trivial applications discussed in XML by Example : Building E-Commerce Applications by Sean McGrath, an older book also discussing the use of XML for e-commerce. In order to help you understand the Java code, the book includes a short crash course on Java, but if you're really interested in advanced XML programming using Java you'd better look at a book like XML and Java: Developing Web Applications by Hiroshi Maruyama et al.
0 Talkback[s] (click to add your comment)