tutorial of the concepts and documentation manipulation
techniques necessary for the most common XSLT tasks.
Featuring an XSLT cookbook, which provides task-oriented
recipes for tackling issues such as converting
or reading in multiple documents at once, this
guide makes it easier to find solutions to most development
problems. Included are a glossary, a reference for XSLT
syntax, and a reference for using the popular XSLT
processors. This guide will help XSLT users get common
transformations done with minimal time and effort.
|
Preface |
ix |
|
About this book |
xi |
|
Acknowledgments |
xiv |
|
About the cover illustration |
xv |
| Part 1 |
Getting started with XSLT |
1 |
| 1 |
A brief tutorial |
3 |
| 1.1 |
What is XSLT (and XSL, and XPath)? |
3 |
|
XSLT and alternatives |
5 |
|
Documents, trees, and transformations |
6 |
| 1.2 |
A simple XSLT stylesheet |
8 |
|
Template rules |
9 |
|
Running an XSLT processor |
11 |
|
An empty stylesheet |
12 |
| 1.3 |
More element and attribute
manipulation |
13 |
|
Manipulating attributes |
14 |
|
Attribute value templates |
15 |
| 1.4 |
Summing up the tutorial |
16 |
| Part 2 |
XSLT user's guide: How do I work
with... |
21 |
| 2 |
XPath |
23 |
| 2.1 |
Location paths, axes, node tests, and
predicates |
24 |
| 2.2 |
Axes |
24 |
|
The child, parent, and attribute axes |
25 |
|
Ancestor and ancestor-or-self |
27 |
|
Preceding-sibling and
following-sibling |
29 |
|
Preceding and following |
32 |
|
Descendant and descendant-or-self |
35 |
|
Self |
39 |
|
Namespace |
40 |
| 2.3 |
Node tests |
41 |
| 2.4 |
Predicates |
43 |
| 3 |
Elements and attributes |
47 |
| 3.1 |
Adding new elements to the result tree |
47 |
| 3.2 |
Changing element names for the result
tree |
50 |
| 3.3 |
Parent, grandparent, sibling, uncle, and
other relative elements: getting their content and
attributes |
50 |
| 3.4 |
Previous, next, first, third, last
siblings |
53 |
| 3.5 |
Converting elements to attributes for the
result tree |
55 |
| 3.6 |
Copying elements to the result tree |
57 |
| 3.7 |
Counting elements and other nodes |
61 |
| 3.8 |
Deleting elements from the result tree |
63 |
| 3.9 |
Duplicate elements, deleting |
64 |
| 3.10 |
Empty elements: creating, checking for |
67 |
| 3.11 |
Moving and combining elements for the
result tree |
69 |
|
Reordering an element's children with
xsl:apply-templates |
69 |
|
Moving text with xsl:value-of |
71 |
| 3.12 |
Selecting elements based on: element name,
content, children, parents |
72 |
| 3.13 |
Adding new attributes |
77 |
| 3.14 |
Converting attributes to elements |
79 |
| 3.15 |
Getting attribute values and names |
80 |
| 3.16 |
Testing for attribute existence and for
specific attribute values |
81 |
| 3.17 |
Reusing groups of attributes |
82 |
| 4 |
Advanced XML markup |
84 |
| 4.1 |
Comments |
84 |
|
Outputting comments |
84 |
|
Reading and using source tree comments |
86 |
| 4.2 |
Entities |
87 |
| 4.3 |
Namespaces |
91 |
|
Namespaces and your result document |
94 |
|
Namespaces and stylesheet logic |
98 |
| 4.4 |
Images, multimedia elements, and other
unparsed entities |
104 |
| 4.5 |
Processing instructions |
106 |
|
Outputting processing instructions |
106 |
|
Reading and using source tree processing
instructions |
108 |
| 5 |
Programming issues |
110 |
| 5.1 |
Control statements |
110 |
|
Conditional statements with "If" and
"Choose" (case) statements |
110 |
|
Curly braces: when do I need them? |
115 |
|
"For" loops, iteration |
118 |
| 5.2 |
Combining stylesheets with include and
import |
126 |
|
xsl:include |
126 |
|
xsl:import |
128 |
| 5.3 |
Named templates |
132 |
| 5.4 |
Debugging |
133 |
|
Runtime messages, aborting processor
execution |
134 |
|
Keeping track of your elements |
137 |
|
Tracing a processor's steps |
140 |
|
Listing the nodes in an XPath
expression |
142 |
| 5.5 |
Extensions to XSLT |
143 |
|
Extension elements |
143 |
|
Using built-in extension functions |
146 |
| 5.6 |
Numbers and math |
149 |
| 5.7 |
Strings |
153 |
|
Extracting and comparing strings |
153 |
|
Search and replace |
160 |
| 5.8 |
Variables and parameters: setting and
using |
164 |
|
Variables |
164 |
|
Parameters |
169 |
| 5.9 |
Declaring keys and performing lookups |
173 |
| 5.10 |
Finding the first, last, biggest, and
smallest |
178 |
| 5.11 |
Using the W3C XSLT specification |
182 |
|
Pairs of confusing related terms |
183 |
|
Other confusing terms |
185 |
| 6 |
Specialized input & output |
187 |
| 6.1 |
HTML and XSLT |
187 |
|
HTML as input |
188 |
|
HTML as output |
190 |
| 6.2 |
Browsers and XSLT |
192 |
|
Internet Explorer |
194 |
|
Netscape Navigator |
194 |
| 6.3 |
Multiple input documents |
195 |
| 6.4 |
Using modes to create tables of contents
and other generated lists |
199 |
| 6.5 |
Non-XML output |
202 |
| 6.6 |
Numbering, automatic |
205 |
| 6.7 |
Sorting |
215 |
| 6.8 |
Stripping all markup from a document |
224 |
| 6.9 |
Valid XML output: including DOCTYPE
declarations |
225 |
| 6.10 |
XML declarations |
228 |
| 6.11 |
Whitespace: preserving and controlling |
229 |
|
xsl:strip-space and xsl:preserve-space |
230 |
|
Indenting |
233 |
|
Adding and removing whitespace with
xsl:text |
236 |
|
Adding tabs to your output |
239 |
|
Normalizing space |
241 |
| 6.12 |
Generating IDs and links |
243 |
| 6.13 |
XSL and XSLT: creating Acrobat files and
other formatted output |
247 |
| 6.14 |
Splitting up output into multiple
files |
253 |
| Part 3 |
Appendices |
257 |
| A |
XSLT quick reference |
259 |
| A.1 |
Top-level elements |
260 |
| A.2 |
Instructions |
263 |
| A.3 |
No category |
266 |
| B |
Running XSLT processors |
269 |
| B.1 |
Running XSLT processors |
269 |
| B.2 |
Saxon |
273 |
| B.3 |
XT |
274 |
| B.4 |
iXSLT |
275 |
| B.5 |
Xalan-Java |
276 |
| B.6 |
Xalan-C++ |
277 |
| B.7 |
Sablotron |
278 |
| B.8 |
MSXSL |
279 |
|
Glossary |
281 |
|
Index |
287 |