Wiley XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition 978-0-470-19274-0 Benutzerhandbuch

Produktcode
978-0-470-19274-0
Seite von 38
1
XSL
T
in
Contex
t
XSLT in Context
This chapter is designed to put XSLT in context. It’s about the purpose of XSLT and the task it was
designed to perform. It’s about what kind of language it is, how it came to be that way, and how it has
changed in version 2.0; and it’s about how XSLT fits in with all the other technologies that you are likely
to use in a typical Web-based application (including, of course, XPath, which forms a vital component of
XSLT). I won’t be saying very much in this chapter about what an XSLT stylesheet actually looks like or
how it works: that will come later, in Chapters 2 and 3.
The chapter starts 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.
Next, I 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.
What Is XSLT?
XSLT (Extensible Stylesheet Language: Transformations) is a language that, according to the very first
sentence in the specification (found at
http://www.w3.org/TR/xslt20/
), is primarily designed for trans-
forming one XML document into another. However, XSLT is also capable of transforming XML to HTML
and many other text-based formats, so a more general definition might be as follows:
XSLT is a language for transforming the structure and content 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.
XML is a simple, standard way to interchange structured textual data between computer programs. Part
of its success comes because it is also readable and writable by humans, using nothing more complicated