Organization


This book is divided up into three parts. Part I contains an overview of all the tools in this book, and it explains the details of Xerces, a tool which is used in conjunction with almost all the other tools discussed in this book. Part II focuses on tools that are particularly useful for developing Web applications—these tools have other purposes as well, but the focus is on Web applications. Part III covers tools that are primarily used to build back-end applications.

Part I: Getting Started with the Apache XML Tools

Part I includes a chapter on Xerces, which is foundational for all the other tools described in the book.

Chapter 1: Xerces

Xerces-J is an XML parsing library that has been used in many large Java applications. It provides support for XML 1.0 with Namespaces and has preliminary support for XML 1.1. Xerces-J supports the W3C DOM Level 2 tree-based API, the SAX 2.0.1 event-driven API, and the Java API for XML Parsing (JAXP) 1.2, which is based on the DOM and SAX APIs. In addition, Xerces-J provides full support for the W3C XML Schema 1.0 recommendation, allowing you the choice of using DTDs or XML Schema when validating XML documents. XML parsing is the foundational layer for any XML processing application, and Xerces provides a stable and flexible foundation. Xerces has been incorporated into so many applications that you may be using it today and not know it.

We’ll look at how to use JAXP with Xerces-J to obtain a parser that you can use from within your application. Then we’ll discuss how you can use either the SAX or DOM APIs to process an XML document. Xerces-J provides additional functionality that isn’t described by any of the standards, so we’ll look at how to use the Xerces configuration mechanism and the Xerces Native Interface to perform tasks that are outside of what the standards describe. Xerces includes a library for serializing XML, taking either SAX event callbacks or a DOM tree and turning them back into an XML document. One of the newest features of Xerces is the ability to cache XML Schemas to avoid reprocessing them when you’re processing a number of documents that use the same schema.

Part II: Web Application Development

Part II is devoted to tools that are useful when you’re developing Web applications. That’s not to say that these tools don’t have other applications; it’s recognition that they can be particularly useful in developing Web applications.

Chapter 2: Xalan

Xalan is the ASF library for working with XSLT, the eXtensible Stylesheet Language (XSL) Transformations language. XSLT is an XML grammar that allows you to specify how an XML document using one vocabulary can be converted into an XML document that uses a different vocabulary. These transforms let you add or subtract information from the document, as well as rearrange the structure of the document. Xalan implements the XSLT 1.0, XPath 1.0, and JAXP 1.2 APIs. You can use XSLT to convert XML of various sorts into HTML, WML, or other display languages based on XML. You can also use it to convert data files from one vocabulary to another.

The JAXP API is the primary method for interacting with Xalan, so we’ll look at how to use it to perform XSLT transformations. Xalan can operate in two modes, interpretive and compiled. In interpretive mode, Xalan interprets the XSLT stylesheet as it transforms the document. In compiled mode, Xalan uses an XSLT-to-Java compiler called XSLTC to compile the stylesheet into a Java class that can then be executed directly. If you’re passing a large number of documents through the same stylesheet, using XSLTC can improve the performance of your application substantially. We’ll also examine the Xalan mechanism for implementing extensions to XSLT using libraries of functions and via custom Java code. The chapter ends by showing you how to implement a Java servlet filter that can be used to add XSLT capabilities to many servlet applications.

Chapter 3: FOP

The XSL recommendation comes in two parts: XSLT and XSL, which is sometimes referred to as XSL-FO (XSL formatting objects). Whereas XSLT is concerned with transforming one flavor of XML into another, XSL-FO takes XML in the form of XSL formatting objects and formats it for output to non-XML formats such as PDF, PCL, and Postscript. The Apache FOP project is an implementation of an XSL processor. It’s capable of rendering XSL formatting objects to PDF, PCL, Postscript, SVG, text, and other file formats.

We’ll look at the FOP SAX- and DOM-based APIs to see how to embed FOP in a Java program. FOP provides some command-line tools that are useful for debugging and testing, as well as some Ant tasks. At the end of the chapter, we’ll discuss how to implement a Java servlet filter that uses FOP as an output stage. We’ll also see how to chain that filter together with the Xalan XSLT filter to obtain a complete system for rendering XML to non-XML formats.

Chapter 4: Batik

People are finding applications for XML in a wide and varied number of problem domains. The Scalable Vector Graphics (SVG) recommendation specifies an XML vocabulary for describing vector graphics operations. SVG allows you to describe dynamic as well as static images, so you can use it to perform animation and build user interfaces. There are two methods for describing SVG animation: a scripting-based method based on an SVG-enabled version of the DOM, and a more declarative method based on elements taken from the Synchronized Multimedia Integration Language (SMIL). SVG provides a way to integrate visual content into XML data. The Batik project is Apache’s library for working with SVG.

The Batik toolkit contains both end-user and developer components. We’ll look at the Batik tools for generating images from SVG files, an SVG browser based on Batik components, and tools that Batik supplies for generating fonts and pretty-printing SVG files. Batik provides a library of classes you can integrate into your application so you can generate SVG documents by using the Java2D drawing API. There is also a Swing-based component for displaying SVG documents; you can add it to your Swing applications to obtain SVG display capabilities. We’ll also examine how Batik integrates with scripting languages such as ECMAScript/JavaScript and JPython.

Chapter 5: Cocoon Concepts

Cocoon is a sophisticated Web publishing framework based on XML. It’s different from most of the other tools we’ll discuss because no standard defines how it works. It’s purely the invention of the Cocoon committers, and it makes heavy use of the rest of the Apache XML libraries.

Cocoon is based on the notion of XML processing pipelines. These pipelines are used to process request URIs and generate results of varying types, including HTML, XHTML, WML, PDF, and others. Cocoon defines eXtensible Server Pages, an XML-compliant equivalent to JavaServer Pages, which you can use to generate XML data for Cocoon pipelines. A new feature in Cocoon is FlowScript, which provides a compact mechanism for capturing complex Web page interactions such as multipage forms.

Cocoon is a big topic, so it’s covered in two chapters—this chapter focuses on Cocoon concepts and terminology, and we look at how to build pipelines.

Chapter 6: Cocoon Development

This chapter focuses on practical applications. We’ll discuss installing and setting up Cocoon. We’ll approach database access from a number of different angles because Cocoon provides a diversity of database access methods. And we’ll show you how to tie all these components together in a simple database-backed Web application.

Chapter 7: Xindice

Once you start marking up data as XML, you’ll discover that you quickly accumulate a lot of information. The question then becomes how to manage all this information. The Xindice project is an attempt to answer that question. Instead of trying to store your XML data in files or as columns or rows in a relational database, Xindice gives you the option of storing your data in a database that has been designed from the beginning to deal with XML. Xindice lets you create collections of documents, index them, and query them using XPath. There are no widely adopted standards in this space, although Xindice does support an API called XML:DB that has been developed by a few native XML database vendors.

We’ll look at setting up a Xindice database and how you go about creating, retrieving, updating, and deleting XML from it. To do this, we’ll discuss the Xindice command-line tools, as well as Xindice’s implementation of the XML:DB APIs. We’ll demonstrate how to integrate Xindice into an XML application by using Xindice as the source of XML data to be processed by the servlet filters developed in earlier chapters.

Part III: Back-End Application Development

Part III discusses three tools that are involved at the back-end plumbing level. You can use them in Web applications and many other back-end application situations.

Chapter 8: XML-RPC

The XML-RPC protocol uses XML to mark up the arguments of a remote procedure call. The resulting XML document is transported to the server using HTTP. This protocol is fairly easy to implement and use, which makes it a popular choice for integrating applications. The main details you need to be aware of are how the XML-RPC library maps types in the host programming language (Java, in our case) onto the set of types defined by XML-RPC. The Apache XML-RPC library is part of the Web services projects at http://ws.apache.org; it’s called Apache XML-RPC.

This chapter shows how to build XML-RPC clients and servers using the Apache XML-RPC library. We’ll also talk about how to perform basic security tasks such authentication and encryption using SSL. The chapter concludes with an example of how to make XML-RPC calls a bit more type safe.

Chapter 9: Axis

Some of the creators of XML-RPC went on to create a more sophisticated version of an XML over HTTP protocol called the Simple Object Access Protocol (SOAP). The SOAP protocol is one the cornerstones of the Web services technology stack. Web services is an attempt to construct systems using an architecture based on loose coupling. Using XML as a marshalling format and HTTP as a transfer protocol is one way to obtain loose coupling. Another cornerstone of the Web services technology stack is the Web Services Description Language (WSDL). This XML vocabulary is used to describe a Web service. A WSDL description can then be used to generate the code that implements a Web service. Apache Axis is a part of the Apache Web services project and is the ASF implementation of both SOAP and WSDL. Axis provides an implementation of the Java API for XML-based RPC (JAX-RPC).

We’ll look at how you write both service providers and service requestors using the Axis / JAX-RPC APIs, and we’ll discuss the Axis deployment descriptor format and how it controls the deployment of Web services when you use Axis. Axis includes powerful command-line tools for taking a WSDL file and generating Java code that implements the service being described in the WSDL file. It also includes tools for processing an existing Java class and creating a WSDL file based on it. In addition, Axis provides a mechanism for creating a message-based service where the Axis runtime does not interpret the contents of the SOAP message, allowing your application to have total control over how the XML message is processed.

Chapter 10: XML-Security

XML is increasingly being used to mark up data that has various kinds of security requirements. Either the data needs to have a guarantee of authenticity, or the data needs to be private or secret. The W3C has developed two recommendations to deal with these issues. The XML Signature Syntax and Processing recommendation details how to represent digital signature information as XML and how to use digital signatures to sign portions of XML documents. The XML Encryption Syntax and Processing recommendation contains a parallel technology for using encryption.

The Apache XML project hosts the XML-Security project, which provides a Java API for working with digital signatures and encryption. The digital signature functionality is stable and has been available for some time. The encryption functionality is in the alpha stage but is usable. This chapter explains the APIs provided by the library and walks you through signing, verifying, encrypting, and decrypting documents and portions of documents.




Professional XML Development with Apache Tools. Xerces, Xalan, FOP, Cocoon, Axis, Xindice
Professional XML Development with Apache Tools: Xerces, Xalan, FOP, Cocoon, Axis, Xindice (Wrox Professional Guides)
ISBN: 0764543555
EAN: 2147483647
Year: 2003
Pages: 95

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net