eBook
Related collections and offers
Overview
Forget those funky robot toys that were all the rage in the '80s, XSLT (Extensible Stylesheet Transformations) is the ultimate transformer. This powerful language is expert at transforming XML documents into PDF files, HTML documents, JPEG files--virtually anything your heart desires. As useful as XSLT is, though, most people have a difficult time learning its many peculiarities. And now Version 2.0, while elegant and powerful, has only added to the confusion.
XSLT Cookbook, Second Edition wants to set the record straight. It helps you sharpen your programming skills and overall understanding of XSLT through a collection of detailed recipes. Each recipe breaks down a specific problem into manageable chunks, giving you an easy-to-grasp roadmap for integrating XSLT with your data and applications. No other XSLT book around employs this practical problem-solution-discussion format.
In addition to offering code recipes for solving everyday problems with XSLT 1.0, this new edition shows you how to leverage the improvements found in XSLT 2.0, such as how to simplify the string manipulation and date/time conversion processes. The book also covers XPath 2.0, a critical companion standard, as well as topics ranging from basic transformations to complex sorting and linking. It even explores extension functions on a variety of different XSLT processors and shows ways to combine multiple documents using XSLT. Code examples add a real-world dimension to each technique.
Whether you're just starting out in XSLT or looking for advanced techniques, you'll find the level of information you need in XSLT Cookbook, Second Edition.
Product Details
ISBN-13: | 9780596553302 |
---|---|
Publisher: | O'Reilly Media, Incorporated |
Publication date: | 12/14/2005 |
Series: | Cookbooks (O'Reilly) |
Sold by: | Barnes & Noble |
Format: | eBook |
Pages: | 778 |
File size: | 4 MB |
About the Author
Table of Contents
Preface | 9 | |
1. | Strings | 1 |
1.1 | Testing if a String Ends with Another String | 2 |
1.2 | Finding the Position of a Substring | 2 |
1.3 | Removing Specific Characters from a String | 3 |
1.4 | Finding Substrings from the End of a String | 4 |
1.5 | Duplicating a String N Times | 6 |
1.6 | Reversing a String | 9 |
1.7 | Replacing Text | 13 |
1.8 | Converting Case | 17 |
1.9 | Tokenizing a String | 19 |
1.10 | Making Do Without Regular Expressions | 22 |
1.11 | Using the EXSLT String Extensions | 23 |
2. | Numbers and Math | 26 |
2.1 | Formatting Numbers | 27 |
2.2 | Rounding Numbers to a Specified Precision | 36 |
2.3 | Converting from Roman Numerals to Numbers | 37 |
2.4 | Converting from One Base to Another | 39 |
2.5 | Implementing Common Math Functions | 43 |
2.6 | Computing Sums and Products | 54 |
2.7 | Finding Minimums and Maximums | 58 |
2.8 | Computing Statistical Functions | 65 |
2.9 | Computing Combinatorial Functions | 68 |
2.10 | Testing Bits | 69 |
3. | Dates and Times | 75 |
3.1 | Calculating the Day of the Week | 77 |
3.2 | Determining the Last Day of the Month | 78 |
3.3 | Getting Names for Days and Months | 79 |
3.4 | Calculating Julian and Absolute Day Numbers from a Specified Date | 82 |
3.5 | Calculating the Week Number for a Specified Date | 85 |
3.6 | Working with the Julian Calendar | 86 |
3.7 | Working with the ISO Calendar | 87 |
3.8 | Working with the Islamic Calendar | 90 |
3.9 | Working with the Hebrew Calendar | 92 |
3.10 | Formatting Dates and Times | 101 |
3.11 | Determining Secular and Religious Holidays | 106 |
4. | Selecting and Traversing | 109 |
4.1 | Optimizing Node Selections | 111 |
4.2 | Determining if Two Nodes Are the Same | 120 |
4.3 | Ignoring Duplicate Elements | 123 |
4.4 | Selecting All but a Specific Element | 127 |
4.5 | Performing a Preorder Traversal | 128 |
4.6 | Performing a Postorder Traversal | 132 |
4.7 | Performing an In-Order Traversal | 134 |
4.8 | Performing a Level-Order Traversal | 138 |
4.9 | Processing Nodes by Position | 143 |
5. | XML to Text | 149 |
5.1 | Dealing with Whitespace | 150 |
5.2 | Exporting XML to Delimited Data | 155 |
5.3 | Creating a Columnar Report | 170 |
5.4 | Displaying a Hierarchy | 180 |
5.5 | Numbering Textual Output | 188 |
5.6 | Wrapping Text to a Specified Width and Alignment | 197 |
6. | XML to XML | 201 |
6.1 | Converting Attributes to Elements | 202 |
6.2 | Converting Elements to Attributes | 204 |
6.3 | Renaming Elements or Attributes | 207 |
6.4 | Merging Documents with Identical Schema | 212 |
6.5 | Merging Documents with Unlike Schema | 217 |
6.6 | Splitting Documents | 223 |
6.7 | Flattening an XML Hierarchy | 224 |
6.8 | Deepening an XML Hierarchy | 228 |
6.9 | Reorganizing an XML Hierarchy | 232 |
7. | Querying XML | 236 |
7.1 | Performing Set Operations on Node Sets | 237 |
7.2 | Performing Set Operations on Node Sets Using Value Semantics | 240 |
7.3 | Determining Set Equality by Value | 249 |
7.4 | Performing Structure-Preserving Queries | 253 |
7.5 | Joins | 255 |
7.6 | Implementing the W3C XML Query-Use Cases in XSLT | 260 |
8. | XML to HTML | 288 |
8.1 | Using XSLT as a Styling Language | 289 |
8.2 | Creating Hyperlinked Documents | 293 |
8.3 | Creating HTML Tables | 296 |
8.4 | Creating Frames | 303 |
8.5 | Creating Data-Driven Stylesheets | 308 |
8.6 | Creating a Self-Contained HTML Transformation | 314 |
8.7 | Populating a Form | 318 |
9. | XML to SVG | 324 |
9.1 | Transforming an Existing Boilerplate SVG | 325 |
9.2 | Creating Reusable SVG Generation Utilities for Graphs and Charts | 332 |
9.3 | Creating a Tree Diagram | 368 |
9.4 | Creating Interactive SVG-Enabled Web Pages | 378 |
10. | Code Generation | 388 |
10.1 | Generating Constant Definitions | 396 |
10.2 | Generating Switching Code | 400 |
10.3 | Generating Message-Handling Stub Code | 405 |
10.4 | Generating Data Wrappers | 408 |
10.5 | Generating Pretty Printers | 412 |
10.6 | Generating a Test Data-Entry Web Client | 420 |
10.7 | Generating Test-Entry Web CGI | 421 |
10.8 | Generating Code from UML Models via XMI | 426 |
10.9 | Generating XSLT from XSLT | 442 |
11. | Vertical XSLT Application Recipes | 449 |
11.1 | Converting Visio VDX Documents to SVG | 450 |
11.2 | Working with Excel XML Spreadsheets | 463 |
11.3 | Generating XTM Topic Maps from UML Models via XMI | 470 |
11.4 | Generating Web Sites from XTM Topic Maps | 490 |
11.5 | Serving SOAP Documentation from WSDL | 504 |
12. | Extending and Embedding XSLT | 518 |
12.1 | Using Saxon's and Xalan's Native Extensions | 525 |
12.2 | Extending XSLT with JavaScript | 537 |
12.3 | Adding Extension Functions Using Java | 543 |
12.4 | Adding Extension Elements Using Java | 549 |
12.5 | Using XSLT from Perl | 563 |
12.6 | Using XSLT from Java | 566 |
13. | Testing and Debugging | 569 |
13.1 | Using xsl: message Effectively | 570 |
13.2 | Tracing the Flow of Your Stylesheet Through Its Input Document | 572 |
13.3 | Automating the Insertion of Debug Output | 577 |
13.4 | Including Embedded Unit Test Data in Utility Stylesheets | 584 |
13.5 | Structuring Unit Tests | 589 |
13.6 | Testing Boundary and Error Conditions | 591 |
14. | Generic and Functional Programming | 595 |
14.1 | Creating Polymorphic XSLT | 600 |
14.2 | Creating Generic Element Aggregation Functions | 607 |
14.3 | Creating Generic Bounded Aggregation Functions | 620 |
14.4 | Creating Generic Mapping Functions | 627 |
14.5 | Creating Generic Node-Set Generators | 635 |
Index | 641 |