Home > Store

XML by Example

Register your product to gain access to bonus material or receive a coupon.

XML by Example

Book

  • Sorry, this book is no longer in print.
Not for Sale

About

Features

  • Complete Coverage
    • Teaches students XML, as well as explaining XML syntax with a list of common errors and misunderstandings. Ex.___

  • E-Commerce Application
    • Walks students through a multi-tier e-commerce application using XML and Java servlets. Ex.___

  • By Example approach
    • Throughout each chapter, students will have short examples to reinforce concepts they have learned. Ex.___

  • Student-friendly pedagogical tools—Include Tips, Notes, Cautions, Cross-References and Chapter Summaries.
    • Helps guide students through the chapters. Ex.___

  • Structured programming techniques.
    • Students will develop a structured programming technique to isolate problems, write correct problems faster, and produce easy-to-maintain programs. Ex.___

  • Java Coverage
    • The appendix gives students added coverage on Java. Ex.___

Description

  • Copyright 1999
  • Edition: 1st
  • Book
  • ISBN-10: 0-7897-2242-9
  • ISBN-13: 978-0-7897-2242-3

XML by Example teaches Web developers to make the most of XML with short, self-contained examples every step of the way. The book presumes knowledge of HTML, the Web, Web scripting, and covers such topics as: Document Type Definitions, Namespaces, Parser Debugging, XSL (Extensible Stylesheet Language), and DOM and SAX APIs. At the end, developers will review the concepts taught in the book by building a full, real-world e-commerce application.

Downloads

Source Code


This file contains the source code for this title - Linux Only - 42KB -- code.tar.gz
Source code from the book - Windows - 122 kb -- code.exe

Sample Content

Sample Pages

Download the sample pages (includes Chapter 3 and Index)

Table of Contents



Introduction.


1. The XML Galaxy.


2. The XMI, Syntax.


3. XML Schemas.


4. Namespaces.


5. XSL Transformation.


6. XSL Formatting Objects and Cascading Style Sheet.


7. The Parser and DOM.


8. Alternative API: SAX.


9. Writing XML.


10. Modeling for Flexibility.


11. N-Tiered Architecture and XML.


12. Putting It All Together: An e-Commerce Example.


Appendix A: Crash Course on Java.


Glossary.


Index.

Updates

Online Support

http://www.quepublishing.com

Updates & Corrections

XML by Example
updated September 28, 2000

The danger of writing about a technology like XML is that it is not 100% stable. Therefore between when I finished writing the book and now, a few things have changed. This page provides updated information.

XJParse

IBM has migrated the XML Parser for Java to the open-source Apache project. This has resulted in many improvement to the parser but, unfortunately in so doing, they also removed XJParse, the command-line interface to the parser. Therefore the commands printed on page 85 and following will not run. To test the example, you will need to download Validate, a replacement for XJParse. In the validate.zip file, you will find a .bat file "validate.bat" which controls the validation. Assuming the XML file is called abook.xml, use the following command to validate it:

validate abook.xml -notree -validate

Listings

These listings have been updated to reflect XSL as supported by LotusXSL version 0.18.5. Therefore they might differ slightly from the same listing published in XML by Example. None of the concepts have changed, but details in the implementation have.

XSL

The W3C has recently approved the final version of XSL. The final standard differs from XSL as presented in XML by Example in two ways:

1. The URI for the namespace has changed to http://www.w3.org/1999/XSL/Transform and a new version attribute has been added to the xsl:stylesheet element.
This element should now read:

<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns="http://www.w3.org/TR/REC-html40">

2. A new element, xsl:output, has been introduced. This new element takes the value of the output parameter that was previously passed as a command-line argument to the XSL processor:

<xsl:output method="html"/>

For example, listing 1.11 would now read:

<?xml version="1.0" encoding="ISO-8859-1"?>

<xsl:stylesheet version="1.0"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   xmlns="http://www.w3.org/TR/REC-html40">

<xsl:output method="html"/>

<xsl:template match="/">
   <HTML>
   <HEAD>
      <TITLE>Pineapplesoft Link</TITLE>
   </HEAD>
   <BODY>
      <xsl:apply-templates/>
   </BODY>
   </HTML>
</xsl:template>

<xsl:template match="section/title">
   <P><I><xsl:apply-templates/></I></P>
</xsl:template>

<xsl:template match="article/title">
   <P><B><xsl:apply-templates/></B></P>
</xsl:template>

<xsl:template match="url">
   <A TARGET="_blank">
      <xsl:attribute name="href">
         <xsl:apply-templates/>
      </xsl:attribute>
      <xsl:apply-templates/>
   </A>
</xsl:template>

<xsl:template match="url[@protocol='mailto']">
   <A>
      <xsl:attribute name="href">mailto:<xsl:apply-templates/>
      </xsl:attribute>
      <xsl:apply-templates/>
   </A>
</xsl:template>

<xsl:template match="p">
   <P><xsl:apply-templates/></P>
</xsl:template>

<xsl:template match="abstract | date | keywords | copyright"/>

</xsl:stylesheet>

LotusXSL

The listings on this Web site have been updated for LotusXSL 0.18.5, the latest version available from Alphaworks.
LotusXSL 0.18.5 is largely backward compatible with the version of XSL described in XML by Example, therefore most examples should run unmodified.

Unfortunately the interface to XSLProcessor has changed with version 0.18.5. This impacts both the command-line and the XCommerce application.

Command-Line

To call LotusXSL from the command-line, you must replace the class com.lotus.xsl.xml4j.ProcessXSL with com.lotus.xsl.Process.

For example, the command-line on page 132 now reads:

java classpath
 c:\lotusxsl\xml4j.jar;c:\lotusxsl\lotusxsl.jar
 com.lotus.xsl.Process
 -in 19990101_xsl.xml
 -xsl simple.xsl -out 19990101_xsl.html html

XCommerce

The version of XMLUtil.java (listing 12.14) on this Web site has been updated to reflect changes in the LotusXSL interface.
XMLServer.java (listing 12.16) has also been updated to fix a problem with the namespace that version 0.18.5 of LotusXSL exposes: The product element contains elements in the Emailaholic namespace but the declaration for the namespace is lost when extracting a product element from the product list. This version attaches the namespace declaration to every product element.

XCommerce is a large application so it's easy to forget one step when installing it. Pay special attention to these points:

- Don't forget to create the file data/xmli.xml as explained in the book or your XMLi shop won't work
- You might want to adapt the URLs in merchants.xml (listing 12.8)
- The password for editor is "xmli". You can change it by editing the file viewedit.prp (listing 12.4)
- Some style sheets are in Chapter 11, such as listing 11.8 to 11.10

Jetty

If you installed Jetty 2.2.x or above, you need to enable its compatibility mode because the format for configuration files has changed. To enable compatibility mode, replace the class name (com.mortbay.Jetty.Server) with (com.mortbay.Jetty.Server21).

For example, to launch XDic (from Appendix A), issue the following command:

set classpath=c:\jetty\lib\javax.servlet.jar;
c:\jetty\lib\com.mortbay.Jetty.jar;.
java com.mortbay.Jetty.Server21 jetty.prp

JDBC

We found compatibility problems with some JDBC databases, in particular Access 97. The listings on this Web site have been updated to improve compatibility. These listings have been fully tested against Access 97. Specifically XMLServer.java and XMLServerConsole.java have been updated.

Changes are minor and listed below:
- Enable auto-commit;
- Name constraints;
- Rename the "image" field "img";
- Explicitly convert the id into an integer in doDelete();
- Explicitly close the ResultSet in isSchemaExist().

Submit Errata

More Information