The XSL Companion

The XSL Companion

by Neil Bradley

Paperback

$33.66 $39.99 Save 16% Current price is $33.66, Original price is $39.99. You Save 16%. View All Available Formats & Editions

Overview

This new edition of the very popular and successful XSL Companion covers all the features of the new XSLT standard.

The XSLT standard is now firmly established as a companion to XML for all manner of transformation needs. Experience with using this standard to solve serious practical problems has resulted in more explanatory material and suggestions on how to exploit it to the fullest.

Because XSLT makes heavy use of XPath, its popularity has also helped establish XPath as theway to navigate through XML documents. XPath is now being incorporated into XML databases as aquery language. It, therefore, deserves more prominence and now has a section of the book to itself.

This practical hands-on guide is split into four convenient sections:

  • Transformations using XSLT — covers the features of the XSLT language;
  • XPath expressions — covers the XPath standard in detail;
  • Formatting with XSL — looks at the XSL standard in depth;
  • References — includes information on other formatting and stylesheet languages, explains how to analyze XML document type definitions (DTDs) and lists the characters in the popular ISO 8859/1 character set.


Product Details

ISBN-13: 9780201770834
Publisher: Addison Wesley Professional
Publication date: 08/01/1902
Pages: 465
Product dimensions: 6.71(w) x 9.10(h) x 0.93(d)

About the Author


Neil Bradley is an XML Consultant with 15 years' practical experience in the field. He is an experienced trainer, a regular speaker at industry events and contributes articles to specialist magazines and journals. He is the author of The Concise SGML Companion and The XML Companion.

Read an Excerpt

PREFACE: This book covers a family of standards developed by W3C (the World Wide Web Consortium). These standards emerged out of a proposal for a stylesheet language, submitted in 1997, which was to be called 'XSL' (extensible Stylesheet Language). However, during its gestation, this proposal was eventually pulled apart into three separate standards. The first of these, XPath, defines a mechanism for locating information in XML documents, and it has many other uses beyond its role in formatting documents. The second, XSLT, provides a means for transforming XML documents into other data formats, including (but not limited to) formatting languages. Finally, the term 'XSL' is now properly used only to name a proposed standard for embedding formatting information in documents using XML elements.

These three standards are still related. Together, they provide a means to format XML documents. The XSLT standard includes XPath constructs in a number of places, and XSLT can be used to convert an XML document into an XSL document. But each can be used alone, or with alternative technologies. As the XSL formatting language is less mature than XSLT, and not yet well supported, it is recognised that XSLT will initially be used primarily to convert XML documents into HTML documents, possibly enhanced with CSS styling instructions. Both these formats are therefore explained in depth. However, the first half of this book concentrates on using XSLT as a general tool for processing XML, and the way that it uses XPath to find and manipulate components of an XML document.

Table of Contents

Prefaceiii
1.Using this book1
Assumptions1
Book structure1
Style conventions2
2.Background concepts5
Transformation languages5
Formatting languages6
Stylesheets7
The XSL standards10
Software support13
Why XSL?15
Example stylesheet16
Transformations using XSLT
3.Templates17
Templates17
Template selection18
Adding boilerplate text23
Default element template24
Hiding content26
Flexible tree-walking26
Processing source text28
Processing instructions and comments29
Tag replacement29
Identity transformations31
Including spaces32
Values of elements and attributes33
Direct processing34
Named templates36
Messages37
4.Stylesheets39
XML-based stylesheet documents39
Using stylesheets40
The Stylesheet element41
Stylesheet contents43
Single template short-cut44
Embedded stylesheets45
Fragmented stylesheets46
Output formats49
Space preservation51
5.Outputting elements55
Element output55
Element generation57
Attributes58
Attribute sets60
Breaking well-formed constraints62
6.XML output65
XML output format65
XML declaration66
Document type declaration67
Comments67
Processing instructions69
Copying source structures71
CDATA sections73
7.HTML output75
Pseudo HTML output75
True HTML output77
8.Text output83
Non-XML output83
Pseudo text output84
Text output mode85
Line-ending issues86
Escaping significant characters88
9.Contextual formatting91
Context considerations91
XML structures92
Expressions93
Alternative elements94
Simple location contexts94
Advanced context97
Attribute context98
Negative context99
Priorities100
10.Choices103
Introduction103
If conditions103
Multiple choices106
11.Expressions in attributes109
Attribute value templates109
Copy-through attributes111
Element to attribute111
Static text and multiple expressions113
Limitations113
12.Reorganizing material115
Information reuse115
Context-specific formatting (modes)117
Moving information118
Accessing other documents119
13.Variables and parameters123
Variables123
Variable types124
Variable definitions126
References127
Boolean values128
Numbers129
Strings130
Node-sets131
Result tree fragments133
No expressions in variables134
References in output attributes135
Complex variable definitions135
Invariable variables137
Other limitations140
Template parameters140
Document parameters142
14.Sorting143
Simple element sorting143
Correct ordering145
Ordering options146
Selective sorting147
Multiple sort criteria149
15.Numbering151
Automatic numbering151
HTML numbering151
Simple numbering152
Expression values155
Elements to count156
Multipart numbering160
Document-wide numbering162
Advanced formatting options164
16.Identifiers and links167
XML IDs167
Keys169
Hypertext links173
17.Namespaces177
Background177
Namespaces in stylesheets177
Namespaces in source documents180
Namespaces in output documents182
Outputting stylesheets (namespace alias)185
18.XSLT extensions189
Extension functions189
Extension elements190
Forward compatibility192
XPath expressions
19.XPath193
The XPath standard193
Expressions in attributes194
20.Patterns197
Introduction197
Element names198
Multiple patterns199
Steps and children199
Root identifier200
Pattern directions201
Attribute patterns201
Intermediate step wildcards202
Axis specifiers203
Node tests204
First step206
Subsequent steps207
Predicate filters208
21.Location paths209
Introduction209
Context node and context list210
Path directions212
Parent axis213
Self axis213
Descendent or self axis214
Other axis directions215
Combined example217
22.Complete XPath expressions219
Introduction219
Expressions in XSLT221
Operators222
Multiple conditions225
Operator precedence226
Sub-expressions228
Boolean functions229
Numeric functions230
String functions232
Node-set values235
Identity and context functions236
Predicate filters238
Namespaces241
23.Added XSLT functions243
Functions covered elsewhere243
Format number function243
Current node function247
Unparsed entity URI function248
System property function249
Formatting with XSL
24.XSL251
Background251
XSL instructions252
Document structure253
25.Page templates257
Page properties257
Page sequences261
Page regions267
26.Flow objects275
Content275
Blocks277
Lines289
In-line objects292
Wrappers302
Whitespace and linefeeds303
27.Advanced XSL features307
Colours307
Markers309
Object positioning312
Out-of-line objects313
Dynamic content314
Aural styles317
References
28.HTML 4.0323
Background323
HTML versions324
Basic document structure325
Differences from XML327
Text blocks328
Basic hypertext links328
Common attributes330
Headings and divisions332
Lists334
In-line elements336
Formatted text338
Images339
Tables341
Descriptive markup347
Styles and scripts348
Frames349
Elements and attributes list352
29.CSS369
Background369
Format primer370
CSS versus XSL/XSLT371
Relevance to XSL and XSLT371
Rule constructions372
Properties374
30.RTF383
Background383
Syntax overview384
XSLT issues386
Paragraphs388
In-line styles391
Colours393
Tables394
Images398
Headers and footers398
Built-in formatting stylesheets399
31.QuarkXPress tags403
QuarkXPress403
XML export tools403
XML import extensions404
Quark Tags importer extension405
Terminology conflicts406
Tagging language principles407
Paragraph styles410
In-line formatting options413
Colours416
Characters416
Indexes418
32.DTD analysis for XSLT stylesheet design421
Introduction421
Elements to style422
Hierarchical context423
Required and sequential context423
Block and in-line elements424
Attributes426
DTD construction features427
33.XSLT DTD429
Introduction429
Top-level elements429
Templates435
Template instructions436
Instruction constructs446
Result elements449
34.ISO 8859/1 character set451
Character set table451
Index457

Preface

This book covers a family of standards developed by the W3C (World WideWeb Consortium). These standards emerged out of a proposal for astylesheet language, submitted in 1997, which was to be called XSL(eXtensible Stylesheet Language). However, during its gestationthis proposal was pulled apart and became three separate standards.XPath defines a mechanism for locating information in XML documents,and has many other uses beyond its role in formatting documents.XSLT (XSL Transformations) provides a means for transforming XMLdocuments into other data formats, including (but not limited to)formatting-focussed markup languages. Finally, the term kXSLm isnow properly used only to name a standard for embedding XML-basedformatting information in documents.

Due to their shared history, these three standards are still relatedand are used together to provide a means to format XML documents,especially in preparation for the particular demands of presentationon print media. The XSLT standard includes XPath constructs in a numberof places, and can be used to convert an XML document that conforms toan arbitrary document model into an XSL document. But each standard canalso be used alone or with alternative technologies. Because the XSLformatting language is less mature than XSLT, and not yet well supported,XSLT is initially being used primarily to convert XML documents in toHTML (or XHTML) documents, possibly enhanced with CSS(Cascading Style Sheets) styling instructions. Both of these formats are thereforeexplained in depth.

When formatted documents have to be edited before they can be presentedor printed, it is necessary to use aword processor or DTP package,but none of these packages yet support XSL as an import format.Two popular import formats existing today are RTF (Rich Text Format) andQuark Tags. Issues concerned with the use of XSLT to convert XMLdocuments into these two formats are discussed.

Second edition

Since the release of the first edition of this book, almost two years ago,much has happened to warrant the creation of a second edition.

The XSLT standard is now firmly established as a companion to XML forall manner of transformation needs, and experience of using thisstandard to solve serious practical problems has resulted in moreexplanatory material and suggestions on how to exploit it to the full.

Because XSLT makes heavy use of XPath, its popularity has also helpedestablish XPath as the way to navigate through XML documents.XPath is now being incorporated into XML databases as a query language.It therefore deserves more prominence and now has a section of the bookto itself.

The XSL standard has now progressed to Recommendation status.This edition covers the final release.

Acknowledgements

Thanks to Rubus for support in developing this book,and to Katherin Ekstrom at Pearson Education. The many individualswho have worked together to develop the standards covered in thisbook richly deserve acknowledgement. Finally, thanks once again toAdobe for FrameMaker+SGML (which was used both in the preparationand publication of this book).

Feedback

Comments and suggestions for a possible future edition are welcomed. Updates,additions and corrections can be obtained from the authorms Webpage

Neil Bradley - April 2002

Customer Reviews

Most Helpful Customer Reviews

See All Customer Reviews