The Simple API for XML SAX

page 20

1.2.4.5 Document Object Model DOM Level 1

The DOM, as we discussed earlier, is a programming API for documents. It defines a set of interfaces and methods used to view an XML document as a tree structure. XSLT and XPath use a similar tree view of XML documents. See http:www.w3.orgTRREC-DOM-Level-1 for more information.

1.2.4.6 Document Object Model DOM Level 2

The DOM Level 2 standard builds on DOM Level 1. It adds several new features: • HTML support, providing a DOM view of HTML documents • CSS and stylesheet interfaces • Document events • Tree traversal methods • Range selection methods • Views of DOM trees, in which the view is separate from the DOM itself The new features of DOM Level 2 dont affect our work directly. If you read the specification, youll see that certain features, such as views, stylesheet interfaces, and tree traversal, provide features useful to an XSLT processor. Although future XSLT processors will be built on XML parsers that provide these functions, that wont change any of the techniques we cover in this book. See http:www.w3.orgTRDOM-Level-2 for the complete specification.

1.2.4.7 Namespaces in XML

As we mentioned earlier, namespaces provide a way to avoid name collisions when two XML elements have the same name. See http:www.w3.orgTRREC-xml-names for more information.

1.2.4.8 Associating stylesheets with XML documents

Its possible to reference an XSLT stylesheet within an XML document. This specification uses processing instructions to define one or more stylesheets that should be used to transform an XML document. You can define different stylesheets to be used for different browsers. See http:www.w3.orgTRxml-stylesheet for complete information. Heres the start of an XML document, with two associated stylesheets: ?xml version=1.0? ?xml-stylesheet href=docbookhtmldocbook.xsl type=textxsl? ?xml-stylesheet href=docbookwapdocbook.xsl type=textxsl media=wap? In this example, the first stylesheet is the default because it doesnt have a media attribute. The second stylesheet will be used when the User-Agent field from the HTTP header contains the string wap , identifying the requester of a document as a WAP browser. The advantage of this technique is that you can define several different stylesheets within a particular document and have each stylesheet generate useful results for different browser or client types. The disadvantage of this technique is that were effectively putting rendering instructions into our XML document, something we prefer to avoid. page 21 If you use Microsoft Internet Explorer Version 5.0 or higher, you can install the Microsofts XSLT processor so that opening an XML document in your browser will cause it to be transformed and rendered automatically. For more details on how to install and configure the XML tools to work with the brower, see http:www.microsoft.comxml . In the previous example, if we opened an XML document that began this way, the browser would transform the XML document according to the rules defined in docbookhtmldocbook.xsl and render the results as if it were any HTML page.

1.2.4.9 Scalable Vector Graphics SVG

The SVG specification defines an XML vocabulary for vector graphics. Described by some as PostScript with angle brackets, it allows you to define images that can be scaled to any size or resolution. See http:www.w3.orgTRSVG for details.

1.2.4.10 Canonical XML Version 1.0

Sometimes comparing two XML documents is necessary when digitally signing an XML document, for example. The Canonical XML specification defines a canonical form of XML that makes comparing two documents easy. See http:www.w3.orgTRxml-c14n for the complete specification.

1.2.4.11 XML digital signatures

A joint effort of the W3C and the Internet Engineering Task Force IETF, XML digital signatures provide a mechanism for storing digital signatures in an XML document. The XML document then provides an envelope used to store, send, and retrieve digital signatures for any kind of digital resource. The latest draft of the specification can be found at http:www.w3.orgTRxmldsig-core .

1.2.4.12 XML Pointer Language XPointer Version 1.0

XPointer provides a way to identify a fragment of a web resource. It uses XPath to identify fragments. For details, see http:www.w3.orgTRxptr .

1.2.4.13 XML Linking Language XLink Version 1.0

XLink defines an XML vocabulary for linking to other web resources within an XML document. It supports the unidirectional links were all familiar with in HTML, as well as more sophisticated links. See http:www.w3.orgTRxlink .

1.3 Installing Xalan

In this section, Ill show you how to install the Xalan XSLT processor. In the next chapter, well create our first stylesheet and use it to transform an XML document. The installation process is pretty simple, assuming you already have a Java Runtime Environment JRE installed on your machine. Although very little of the code we look at in this book uses Java, the Xalan XSLT processor itself is written in Java. Once youve installed the JRE, go to http:xml.apache.orgxalan-j and download the latest stable build of the code. If youre feeling brave, feel free to download last nights build instead. Once the Xalan .zip or .gzip file is downloaded, unpack it and add three files to your CLASSPATH . The three files include the .jar file for the Xerces parser, the .jar file for the Xalan stylesheet engine itself, and the .jar file for the Bean Scripting Framework. As of this writing, the .jar files are named xerces.jar, xalan.jar, and bsf.jar.