Your 200-page Personal Trainer for XSL!
To learn how to use XSL, you need practical hands-on advice from an expert who understands what it is like to just start out. By working step by step through document structures, template rules, stylesheet transformations, and formatting objects, you can master XSL fundamentals while learning how to transform structured data into any output format needed from HTML to XHTML to program source code.
This book is designed for anyone who wants to learn XSL, including those who create or support XML applications and XML-based solutions. Inside, you'll find comprehensive overviews, step-by-step procedures, frequently used tasks, documented examples, and much more. One of the goals is to keep the content so concise that the book remains compact and easy to navigate while at the same time ensuring that the book is packed with as much information as possible--making it a valuable resource.
Learning XSL doesn't have to be a frustrating experience, you can use XSL: The Personal Trainer for XSLT, XPath and XSL-FO to learn everything you need to use XSL and related technologies effectively. Look also for XML, DTDs, Schemas: The Personal Trainer.
Table of Contents
Chapter 1. XSL Transformations & Formatting 14
Introducing XSLT 14
Matching Document Structures to Template Rules 18
The Template for Element and Root Nodes 20
The Template for Modes 20
The Template for Text and Attribute Nodes 21
Understanding Other Built-In Templates 21
Structuring XSLT Stylesheets 22
Starting the XSLT Stylesheet 22
Defining the Output Format 24
Defining Template Rules and Declarations 41
Chapter 2. XPath Operators & Expressions 48
Understanding Location Paths 49
Understanding XPath Operators and Datatypes 55
Using Relative XPath Expressions with Elements 60
Referencing the Current Context Node 60
Referencing a Parent Node 61
Referencing Siblings Relative to the Current Context 62
Referencing Child Nodes 63
Using Absolute XPath Expressions with Elements 65
Locating Nodes 67
Working with Attribute Nodes 67
Working with Text Nodes 70
Working with Comment Nodes 71
Working with Processing Instruction Nodes 72
Using Namespaces with Element and Attribute Nodes 73
Using Wildcards and Predicates in XPath Expressions 75
Selecting Any Node 75
Skipping Levels in the Hierarchy 77
Filtering To Match Nodes 79
Chapter 3. Branching & Control Functions 86
Processing with if Statements 86
Processing with choose Statements 89
Processing with for-each Statements 92
Invoking, Including, and Importing Templates 97
Including and Importing Templates 97
Calling Templates by Name 101
Invoking Templates by Mode 102
Chapter 4. Variables & Parameters in XSLT 106
Working with Parameters 106
Defining and Referencing Parameters 106
Setting Default Values for Parameters 108
Passing Parameter Values to Templates 111
Using Global Parameters 113
Working with Variables 120
Defining Variables 120
Referencing Variables 123
Using Global Variables 125
Chapter 5. Working with Strings, Booleans, & Numbers 128
Manipulating Strings 128
Converting Values to Strings 128
Managing Spaces Within Strings 130
Normalizing Space in Strings 134
Merging Values into a Single String 135
Examining and Manipulating String Contents 136
Translating Characters in Strings 145
Converting and Manipulating Boolean Values 147
Using the true() Function 151
Using the false() Function 151
Using the not() Function 151
Working with Numeric Values 151
Converting Values to Numbers 151
Formatting Values as Numbers 153
Rounding Numbers 159
Summing Values 161
And Much more!