XML and Java From Scratch

XML and Java From Scratch

1.0 1
by Nicholas Chase, Jesse Liberty
     
 
XML and Java from Scratch is designed to teach XML and Java in the context of building a real, working Web site and application. All the information on products, prices, vendors, and so on is rendered in XML and the reader learns how to display products on the company Web site, take orders, produce a paper catalog, and communicate with the external databases of

Overview

XML and Java from Scratch is designed to teach XML and Java in the context of building a real, working Web site and application. All the information on products, prices, vendors, and so on is rendered in XML and the reader learns how to display products on the company Web site, take orders, produce a paper catalog, and communicate with the external databases of vendors using XML. Using informative icons-such as Geek Speak and Excursions Nicholas Chase teaches you the correct pronunciation of key terms and discusses interesting subject-related side notes that pertain to the topic at hand.

  • Use the simple principles of XML to store and manipulate data and to build basic Web pages
  • Transform content with XSL for easier viewing and usability
  • Manipulate vendor data with JDOM for greater extensibility
  • Organize inventory structures with namespaces and DOM
  • Search databases with XQL
  • Use SOAP to interact with external systems

Editorial Reviews

Booknews
Illustrates the principles of XML by building a web site and application for a fictitious catalog furniture company. Chapters cover cascading style sheets, XSL processors, document type definitions, parsers, manipulating vendor data with JDOM, organizing inventory structure with namespaces and DOM, and using Java to access legacy SQL databases in conjunction with XML. Annotation c. Book News, Inc., Portland, OR (booknews.com)

Product Details

ISBN-13:
9780789724762
Publisher:
Que
Publication date:
03/19/2001
Series:
From Scratch Series
Pages:
496
Product dimensions:
7.39(w) x 9.03(h) x 1.11(d)

Read an Excerpt

Chapter 2: Product Pages: Transforming XML in the Browser Using XSL

Chapter 1 talked about markup languages in general and HTML and XML L in particular. Specifically, we discussed the separation of content and presentation.

One of the ways we did that was to take our HT ML content, which was rich in pre- sentation but didn't give us a lot of information about the content, and change it to XML, which told us everything we needed to know about the content but nothing about the presentation. We then used Cascading Style Sheets (CSSs) to control the presentation of our XML elements.

In this chapter, we take this a step further. Extensible Stylesheet Language, or XSL, allows you to do everything you could do with CSSs and much more.

The Two Faces of XSL: XSL Transformations and XSL Formatting Objects XSL is actually a pair of potential standards, XSL Transformations or XSLT (version 1.0 of which is already a full W3C Recommendation, and version 1.1 of which has been proposed), and XSL Formatting Objects, or XSLFO. Each is designed to do a different task when it comes to XML data.

XSLT allows us to take XML content and literally transform it into something else, whether that something else is an HTML page, a text file, or even another XML document. We can choose the content we want to display, add content, or even reorder the content that is there. XSLT can work in conjunction with CSS by converting XML to HTML and adding CSS style information to those tags, or by simply creating the page to which CSS information is later applied.

XSLFO is similar to CSS. In fact, not only does it do the same thing as CSS, it is based on CSS and uses essentially the same attributes and values as its predecessor. So, why do we need it? Why not use CSS exclusively?

One of the strengths of XML is the fact that it can be used on many different platforms and not just a browser. Because of this, you could easily find yourself in a situation where your environment understands XML, but the HTML that contains or refers to the style information means nothing.

XSL Formatting Objects become part of the "result tree" you end up with after a transformation and can be processed by any application that supports them.

Getting Ready

At the time of this writing, only one major browser supports XSLT That browser is Microsoft Internet Fxplorer 5 and 5.5. As installed, however, it uses an older working draft of the Recommendation. Using the Recommendation requires downloading the latest version of MSXML3.

Installing MSXML3

Although it should be straightforward to download and install MSXML3, there have been numerous reports of systems that cease all XSL processing after it has been installed. Users have two options:

• Install MSXIVIL3 in "side-by-side" mode, which is the default, making sure to back up c: \windows\ system\MSXML.DLL first. If this file is corrupted and XSL processing stops, replacing it with the backup should allow you to at least use the following option. • Keep the default installation and use the working draft. Most of the information covered in this chapter is the same for both, and we'll note the one exception where it's not. Later, when we move to processing XSLT on the server instead of the client, we can use the Recommendation in its entirety, producing XHTML pages so that we don't need to worry about browser support for XSL when we build our applications.

Installation of NISX_ML3 involves the following steps:

1. Make sure that you have the Windows Installer on your machine. It can be downloaded from http://www.microsoft.com/iflsdownload/platformsdk/instmsi.htm Install this software, close the browser, and restart it.

2. Download the software. We are using the release version of MSXML3 with Microsoft Internet Explorer 5.5 It can currently be found at http://msdn.microsoft.com/xml/c-frame.htm?/xml/general/xmlparser.asp

If you have a previous version of MSXML installed, you may want to upgrade at this point, as some of the results we'll be seeing in this chapter differ with each version.

3. Make a backup copy of c: \windows\ system\MSXML.DLL, as mentioned previously.

4. Run the downloaded file by double-clicking the msxml3.exe file.

5. In some cases, this might not complete the installation, as the default is "sideby-side mode," which leaves the old DLL intact. You will be able to tell when you run the following test. If you find that you don't see the results of the test, you may need to run an additional installation file, xmlinst.exe. It can be downloaded from http://msdn.microsoft.com/downloads/default.asp?URL=/ code/sample.asp?url=/msdn-files/027/001/469/msdncompositedoc.xml

After you have downloaded it, double-click it to uncompress the files. Be sure to make note of where you've uncompressed them to. In a Command Prompt window, change to that directory and type xmlinst

This will complete the installation.

Although I have yet to see it, Microsoft warns that some systems can become unstable after running xmlinst . exe, so run it only if you can't get the installation to pass the following test. To undo the effects of xmlinst. exe, navigate to the appropriate directory and type xmlinst /u

Testing the Installation

To make sure the new software is being used, create the following two files in Listings 2.1 and 2.2 in the same directory. Don't worry about the content for now-we'll be looking at what it all means as soon as we know the software's working properly...

Meet the Author

Nicholas Chase has been involved in Web site development for companies such as Lucent Technologies, Sun Microsystems, and Oracle Corporation. He got his first email account in 1989, and before immersing himself in the Web, he was a physicist, a high school teacher, a low-level radioactive-waste facility manager, an online science fiction magazine editor, a multimedia engineer, and an Oracle instructor. He is currently the chief technology officer of Site Dynamics Interactive Communications in Clearwater, Florida. He is also the author of Active Server Pages 3.0 form scratch. He enjoys watching sunsets with his lovely wife Sarah and their teenage son Sean.

Customer Reviews

Average Review:

Write a Review

and post it to your social network

     

Most Helpful Customer Reviews

See all customer reviews >