XML has firmly established itself as the universal standard for managing data for the web and is now being implemented on a wide scale.
XSL (eXtensible Stylesheet Language), a vital companion to XML, is used for two main purposes: to format or style XML data so that it can be displayed in a browser and to transform XML data (XSLT). When you transform an XML document, you manipulate the data into a new structure, for example, re-ordering the data. This enables the same data store to be used in an unlimited number of ways. XSLT is a flexible, customizable, and cross-platform language.
XSLT is a notoriously difficult language to understand, but this book, while being a complete reference to the recommendation, will also give code examples showing how it all ties together and can be effectively employed in a real-world development scenario. This compact, relevant, updated version reflects recent changes in the XML specification and developments in XSLT parsers. The material on tools and implementations has been revised; so too have all the examples. It also includes a new chapter on writing extension functions.
This reference defines the syntax rules, attributes, effect, and usage of the key language features of XSLT, and offers design advice and case studies for the advanced user. Elements, expressions, patterns, and functions are listed alphabetically in separate sections. The second edition reflects the new working draft of XSLT 1.1., and adds more descriptions of XSLT products. Annotation c. Book News, Inc., Portland, OR
More Reviews and RecommendationsMichael Kay has spent most of his career as a software designer and systems architect, and has recently moved to Software AG, where he is specialising in XML database and transformation technology. He also represents Software AG on the W3C XSL Working Group. Previously he worked on a number of electronic commerce and publishing projects with ICL, the IT services supplier. His background is in database technology: he has worked on the design of network, relational, and object-oriented database software products as well as a text search engine. In the XML world he is known as the developer of the open source Saxon product.
Michael lives in Reading, Berkshire with his wife and daughter. His hobbies, as you might guess from the examples in this book, include genealogy and choral singing.
The Barnes & Noble Review
As we've often said, the true power of XSL lies in its ability to transform content for myriad uses. The language XSL uses to perform this magic is XSLT. It's flexible, customizable, cross-platform, and (as author Michael Kay observes), notoriously difficult to understand. That's why you need Kay's XSLT 1.1 Programmer's Reference, Second Edition.
Kay begins by offering needed context -- helping you understand what XSLT can do, how it evolved from the even more bewildering DSSSL, and its key attributes (for example, its reliance on rules and on XML syntax). Kay reviews the XSLT processing model, as well as the structure of XSLT stylesheets. Next, he offers an example-rich reference to XSLT's key elements, expressions, patterns, and functions.
All the examples in this new Second Edition have been updated to reflect improvements in the XSLT 1.1 standard and the latest generation of XSLT parsers. You'll also find a new chapter on writing extension functions, which enable you to call custom C functions from an XSL stylesheet.
The book includes appendices covering the latest parsers, including Microsoft's MSXML3, Xalan, Oracle, and Kay's own well-regarded SAXON processor. (Bill Camarda)
Bill Camarda is a consultant and writer with nearly 20 years' experience in helping technology companies deploy and market advanced software, computing, and networking products and services. His 15 books include Special Edition Using Word 2000 and Upgrading & Fixing Networks For Dummies®, Second Edition.
"This book is for programmers who want to learn how to use the XSLT language for developing web applications. The book is in four parts: a detailed introduction to the concepts of the language, a reference section giving comprehensive specifications and working examples of every feature, a development guide giving design advice and case studies for the advanced user, and a product reference detailing the features and usage of the latest versions of Microsoft MSXML, Apache Xalan, Oracle XML, open source Saxon, the TRAX API and other processors and tools."--BOOK JACKET.
This reference defines the syntax rules, attributes, effect, and usage of the key language features of XSLT, and offers design advice and case studies for the advanced user. Elements, expressions, patterns, and functions are listed alphabetically in separate sections. The second edition reflects the new working draft of XSLT 1.1., and adds more descriptions of XSLT products. Annotation c. Book News, Inc., Portland, OR
I shall begin by describing the task that XSLT is designed to perform – transformation – and why there is the need to transform XML documents. I'll then present a trivial example of a transformation in order to explain what this means in practice.
The chapter then moves on to discuss the relationship of XSLT to other standards in the growing XML family, to put its function into context and explain how it complements the other standards.
I'll describe what kind of language XSLT is, and delve a little into the history of how it came to be like that. If you're impatient you may want to skip the history and get on with using the language, but sooner or later you will ask "why on earth did they design it like that?" and at that stage I hope you will go back and read about the process by which XSLT came into being.
Finally, I'll have a few things to say about the different ways of using XSLT within the overall architecture of an application, in which there will inevitably be many other technologies and components each playing their own part.
XSLT is a language for transforming the structure of an XML document.
Why should you want to do that? In order to answer this question properly, we first need to remind ourselves why XML has proved such a success and generated so much excitement.
In order to communicate with a human reader, this something else might be a document that can be displayed or printed: for example an HTML file, a PDF file, or even audible sound. Converting XML to HTML for display is probably the most common application of XSLT today, and it is the one I will use in most of the examples in this book. Once you have the data in HTML format, it can be displayed on any browser.
In order to transfer data between different applications we need to be able to transform data from the data model used by one application to the model used in another. To load the data into an application, the required format might be a comma-separated-values file, a SQL script, an HTTP message, or a sequence of calls on a particular programming interface. Alternatively, it might be another XML file using a different vocabulary from the original. As XML-based electronic commerce becomes widespread, so the role of XSLT in data conversion between applications also becomes ever more important. Just because everyone is using XML does not mean the need for data conversion will disappear. There will always be multiple standards in use. For example, the newspaper industry is likely to use different formats for exchanging news articles from the format used in the broadcasting industry. Equally, there will always be a need to do things like extracting an address from a purchase order and adding it to an invoice. So linking up enterprises to do e-commerce will increasingly become a case of defining how to extract and combine data from one set of XML documents to generate another set of XML documents: and XSLT is the ideal tool for the job.
At the end of this chapter we will come back to specific examples of when XSLT should be used to transform XML. For now, I just wanted to establish a feel for the importance and usefulness of transforming XML. Before we move on to discuss XSLT in more detail and have a first look at how it works, let's take a look at an example that clearly demonstrates the variety of formats to which we can transform XML, using XSLT.
If you look there, you will find half a dozen different XML schemas for describing music. These were all invented with different purposes in mind: a markup language used by a publisher for printing sheet music has different requirements from one designed to let you listen to the music from a browser. MusicML, for example, is oriented to displaying music notation graphically; ChordML is designed for encoding the harmonic accompaniment to vocal lyrics; MusicXML is designed to represent musical scores, specifically western musical notation from the 17th century onwards, while the rather more academic Music Markup Language (MML) from the University of Pretoria is designed for serious musicological analysis, embracing Eastern and African as well as Western musical idioms....
...So you could use XSLT to process marked-up music in many different ways:
Links to information about Motorola's VoxML Voice Markup Language can
be found at http://www.oasis-open.org/cover/voxML.html
Let's now delve into the first stage, transformation – the stage with which XSLT is primarily concerned and which makes it possible to provide output in all of these formats. This stage might involve selecting data, aggregating and grouping it, sorting it, or performing arithmetic conversions such as changing centimeters to inches.
So how does this come about? Before the advent of XSLT, you could only process incoming XML documents by writing a custom application. The application wouldn't actually need to parse the raw XML, but it would need to invoke an XML parser, via a defined Application Programming Interface (API), to get information from the document and do something with it. There are two principal APIs for achieving this: the Simple API for XML (SAX) and the Document Object Model (DOM).
The SAX API is an event-based interface in which the parser notifies the application of each piece of information in the document as it is read. If you use the DOM API, then the parser interrogates the document and builds a tree-like object structure in memory. You would then write a custom application (in a procedural language such as C++, Visual Basic, or Java, for example), which could interrogate this tree structure. It would do so by defining a specific sequence of steps to be followed in order to produce the required output. Thus, whatever parser you use, this process has the same principal drawback: every time you want to handle a new kind of XML document, you have to write a new custom program, describing a different sequence of steps, to process the XML.
Both the DOM and the SAX APIs are fully described in the Wrox Press book Professional XML, ISBN 1-861003-11-0.
So how is using XSLT to perform transformations on XML better than writing "custom applications"? Well, the design of XSLT is based on a recognition that these programs are all very similar, and it should therefore be possible to describe what they do using a high-level declarative language rather than writing each program from scratch in C++, Visual Basic, or Java. The required transformation can be expressed as a set of rules. These rules are based on defining what output should be generated when particular patterns occur in the input. The language is declarative, in the sense that you describe the transformation you require, rather than providing a sequence of procedural instructions to achieve it. XSLT describes the required transformation and then relies on the XSLT processor to decide the most efficient way to go about it.
XSLT still relies on an XML parser – be it a DOM parser or a SAX-compliant one – to convert the XML document into a tree structure. It is the structure of this tree representation of the document that XSLT manipulates, not the document itself. If you are familiar with the DOM, then you will be happy with the idea of treating every item in an XML document (elements, attributes, processing instructions etc.) as a node in a tree. With XSLT we have a high-level language that can navigate around a node tree, select specific nodes and perform complex manipulations on these nodes.
The XSLT tree model is similar in concept to the DOM but it is not the same. The full XSLT processing model is discussed in Chapter 2.
The description of XSLT given thus far (a declarative language that can navigate to and select specific data and then manipulate that data) may strike you as being similar to that of the standard database query language, SQL. Let's take a closer look at this comparison....
loading...
loading...
loading...
Terms of Use, Copyright, and Privacy Policy
© 1997-2009 Barnesandnoble.com llc