XML and SQL Server 2000

Just because you are given XML data in a specific layout doesn't mean that is the final format in which the data is required. For one thing, the tag layout might have to be completely rearranged. Maybe, instead of individual departmental budget data, a total budget dollar amount is all that is needed. Enter XSLT. With this new XML- related language (that's right, it is considered to be a complete language, as you'll find out in this chapter), it is possible to take a raw XML document and transform it into whatever format is required. An XML document can be completely rearranged into another XML document, or it can be changed to an HTML document for display on the World Wide Web.You can generate or modify just about any format you can think of by utilizing XSLT.

The Whole Is Greater than the Sum of Its Parts

I'd like to take this discussion just a little bit further and use an analogy to illustrate an important point about XML. Those of you who are familiar with the Transmission Control Protocol/Internet Protocol (TCP/IP) know that it is composed of many individual, different protocols, each with its own specific job to carry out. We call it a suite of protocols. Those of you who are not familiar with TCP/IP might recognize some of these other acronyms. Do you send or receive email? Simple Mail Transfer Protocol (SMTP) is a separate TCP/IP protocol that probably everyone who reads this book uses at least once a day. It is what transfers your email for you. Do you download or upload files on the World Wide Web? The TCP/IP protocol that makes this happen is the File Transfer Protocol (FTP).

Why am I all of a sudden talking about TCP/IP in an XML and SQL Server book? I want you to understand the old saying, "The whole is greater than the sum of its parts." The XML specification doesn't accomplish as much by itself as it does when it is combined with the other "X" specifications: XSLT, XPath, XBase, and XLink just to name a few. When the parts are combined as needed, much more can be accomplished than with what appears on the surface. We will accomplish quite a bit with the skills learned in this book.

Let's get back to XSLT for the time being. XSLT is a subset of the Extensible Stylesheet Language (XSL). XSL, as of this writing, is not an official standard just yet, but it will be one by the time this book is published. The other part of XSL that deals with the XML vocabulary for specifying formatting semantics is XSL Formatting Objects (XSLFO). We will not be discussing XSLFO in this book.

XSLT itself became a W3C Recommendation on November 16, 2000, and is located at http://www.w3.org/TR/1999/REC-xslt-19991116. To show how quickly things are moving forward with XSLT, on December 12, 2000, the W3C released the "XSLT 1.0 Errata" documentation; on December 13, 2000, the first draft of XSLT 1.1 was published. This should clearly demonstrate that a lot of attention is being focused on XSLT and its improvement, and the next couple years of its growth from child to teen should be very interesting.

XSL Editor

Before we get started on the details of XSLT stylesheets, I want to recommend a tool that will help you learn these stylesheets with a minimum of pain on your part. IBM has written a Java-based program called XSL Editor, and it is available at http://www.alphaworks.ibm.com/tech/xsleditor. How this program functions is covered in Appendix F, "IBM's XSL Editor." This is a very simple piece of software, so the learning curve is absolutely minimal. The only disadvantage to this software is that it must run on an older version of Java, 1.x. It will not work on the newer versions. Perhaps IBM will have this fixed by the time this book is published.

Because it is a Java-based program, you will need to get the Java runtime environment that is downloadable from http://java.sun.com. Now, all you non-Java programmers don't worry about it! All you have to do is install the run-time environment; there's not a whole lot to it. Then you install XSL Editor. It will find the Java environment itself; you don't have to tell it anything. Look at the length of Appendix F. That should show you it couldn't be that big of a problem to learn.

Категории