Synopses & Reviews
Critical for converting XML documents, and extremely versatile, the XSLT language nevertheless has complexities that can be daunting. The XSLT Cookbook is a collection of hundreds of solutions to problems that Extensible Stylesheet Language Transformations (XSLT) developers regularly face. The recipes range from simple string-manipulation and mathematical processing to more complex topics like extending XSLT, testing and debugging XSLT stylesheets, and graphics creation with SVG. Recipes can be run directly or tweaked to fit your particular application's needs more precisely.Each recipe walks through a problem and a solution, with explanations of the choices made and techniques used in creating that solution, and many recipes include alternate solutions and explore issues like convenience and performance. Topics covered include:
- String manipulation
- Mathematical processing
- Date and time handling
- Interactions between calendar systems
- Selecting content in source documents
- Efficient tree-manipulation
- Conversions from XML to plain text
- Tweaking XML documents with stylesheets
- Using XSLT to query XML documents
- Generating HTML with XSLT
- Creating charts and graphs with SVG and XSLT
- Generating C and XSLT code using XSLT
- Processing Visio documents in XSLT
- Working with XML Topic Maps (XTM)
- Using XSLT to create SOAP documentation from WSDL
- Extending XSLT with additional functions
- Embedding XSLT in other processing
- Testing and debugging XSLT stylesheets
- Creating generic XSLT processors which work on many XML vocabularies
The
XSLT Cookbook provides an ideal companion both for developers still figuring out XSLT's template-based approach who want to learn by example, and for developers who know XSLT and want a collection of quickly reusable recipes. XSLT frequently offers a number of ways to perform a transformation, and the best solution may not always be the most straightforward. The recipes in this Cookbook demonstrate and explain XSLT's template-based logic, a frequent stumbling block for developers new to XSLT. Among the variety of XSLT books now available, none has the explicit solution-oriented approach of this Cookbook.
Synopsis
Critical for converting XML documents, and extremely versatile, the XSLT language nevertheless has complexities that can be daunting. The XSLT Cookbook is a collection of hundreds of solutions to problems that Extensible Stylesheet Language Transformations (XSLT) developers regularly face. The recipes range from simple string-manipulation and mathematical processing to more complex topics like extending XSLT, testing and debugging XSLT stylesheets, and graphics creation with SVG. Recipes can be run directly or tweaked to fit your particular application's needs more precisely.
Each recipe walks through a problem and a solution, with explanations of the choices made and techniques used in creating that solution, and many recipes include alternate solutions and explore issues like convenience and performance.
About the Author
Sal Mangano has been developing software since the days Borland Turbo C and has worked with an eclectic mix of programming languages and technologies. Sal worked on many mission-critical applications, especially in the area of financial-trading applications. In his day job, he works mostly with mainstream languages like C++ and Java so he chooses to play with more interesting technology whenever he gets a chance.
Sal's two books (XSLT Cookbook and Math Mathematica Cookbook) may seem to be an odd pair of technologies for a single author but there is a common theme that reflects his view at what makes a language powerful. Both Mathematica and XSLT rest on the idea of pattern matching and transformation. They may use these patterns in different ways and transformations to achieve different ends but they are both good at what they do and interesting to program in for a common reason. Sal's passion for these languages and ideas comes through in both these cookbooks. He also likes to push technologies as far as they can go and into every nook and cranny of application. This is reflected in the wide mix of recipes he assembled for these books.
Sal has a Master's degree in Computer Science from Polytechnic University.
Table of Contents
Preface; Structure of This Book; Conventions Used in This Book; How to Contact Us; Acknowledgments; Chapter 1: Strings; 1.1 Testing if a String Ends with Another String; 1.2 Finding the Position of a Substring; 1.3 Removing Specific Characters from a String; 1.4 Finding Substrings from the End of a String; 1.5 Duplicating a String N Times; 1.6 Reversing a String; 1.7 Replacing Text; 1.8 Converting Case; 1.9 Tokenizing a String; 1.10 Making Do Without Regular Expressions; 1.11 Using the EXSLT String Extensions; Chapter 2: Numbers and Math; 2.1 Formatting Numbers; 2.2 Rounding Numbers to a Specified Precision; 2.3 Converting from Roman Numerals to Numbers; 2.4 Converting from One Base to Another; 2.5 Implementing Common Math Functions; 2.6 Computing Sums and Products; 2.7 Finding Minimums and Maximums; 2.8 Computing Statistical Functions; 2.9 Computing Combinatorial Functions; 2.10 Testing Bits; Chapter 3: Dates and Times; 3.1 Introduction; 3.2 Calculating the Day of the Week; 3.3 Determining the Last Day of the Month; 3.4 Getting Names for Days and Months; 3.5 Calculating Julian and Absolute Day Numbers from a Specified Date; 3.6 Calculating the Week Number for a Specified Date; 3.7 Working with the Julian Calendar; 3.8 Working with the ISO Calendar; 3.9 Working with the Islamic Calendar; 3.10 Working with the Hebrew Calendar; 3.11 Formatting Dates and Times; 3.12 Determining Secular and Religious Holidays; Chapter 4: Selecting and Traversing; 4.1 Optimizing Node Selections; 4.2 Determining if Two Nodes Are the Same; 4.3 Ignoring Duplicate Elements; 4.4 Selecting All but a Specific Element; 4.5 Performing a Preorder Traversal; 4.6 Performing a Postorder Traversal; 4.7 Performing an In-Order Traversal; 4.8 Performing a Level-Order Traversal; 4.9 Processing Nodes by Position; Chapter 5: XML to Text; 5.1 Dealing with Whitespace; 5.2 Exporting XML to Delimited Data; 5.3 Creating a Columnar Report; 5.4 Displaying a Hierarchy; 5.5 Numbering Textual Output; 5.6 Wrapping Text to a Specified Width and Alignment; Chapter 6: XML to XML; 6.1 Converting Attributes to Elements; 6.2 Converting Elements to Attributes; 6.3 Renaming Elements or Attributes; 6.4 Merging Documents with Identical Schema; 6.5 Merging Documents with Unlike Schema; 6.6 Splitting Documents; 6.7 Flattening an XML Hierarchy; 6.8 Deepening an XML Hierarchy; 6.9 Reorganizing an XML Hierarchy; Chapter 7: Querying XML; 7.1 Performing Set Operations on Node Sets; 7.2 Performing Set Operations on Node Sets Using Value Semantics; 7.3 Determining Set Equality by Value; 7.4 Performing Structure-Preserving Queries; 7.5 Joins; 7.6 Implementing the W3C XML Query-Use Cases in XSLT; Chapter 8: XML to HTML; 8.1 Using XSLT as a Styling Language; 8.2 Creating Hyperlinked Documents; 8.3 Creating HTML Tables; 8.4 Creating Frames; 8.5 Creating Data-Driven Stylesheets; 8.6 Creating a Self-Contained HTML Transformation; 8.7 Populating a Form; Chapter 9: XML to SVG; 9.1 Transforming an Existing Boilerplate SVG; 9.2 Creating Reusable SVG Generation Utilities for Graphs and Charts; 9.3 Creating a Tree Diagram; 9.4 Creating Interactive SVG-Enabled Web Pages; Chapter 10: Code Generation; 10.1 Generating Constant Definitions; 10.2 Generating Switching Code; 10.3 Generating Message-Handling Stub Code; 10.4 Generating Data Wrappers; 10.5 Generating Pretty Printers; 10.6 Generating a Test Data-Entry Web Client; 10.7 Generating Test-Entry Web CGI; 10.8 Generating Code from UML Models via XMI; 10.9 Generating XSLT from XSLT; Chapter 11: Vertical XSLT Application Recipes; 11.1 Converting Visio VDX Documents to SVG; 11.2 Working with Excel XML Spreadsheets; 11.3 Generating XTM Topic Maps from UML Models via XMI; 11.4 Generating Web Sites from XTM Topic Maps; 11.5 Serving SOAP Documentation from WSDL; Chapter 12: Extending and Embedding XSLT; 12.1 Saxon Extension Functions; 12.2 Saxon Extension Elements; 12.3 Xalan Java 2 Extension Functions; 12.4 Java Extension Function Using the Class Format Namespace; 12.5 Java Extension Function Using the Package Format Namespace; 12.6 Java Extension Function Using the Java Format Namespace; 12.7 Scripting Extension Function Using Inline Script Code; 12.8 Xalan Java 2 Extension Elements; 12.9 Java Extension Element; 12.10 Scripting Extension Elements; 12.11 MSXML Extension Functions; 12.12 Using Saxon's and Xalan's Native Extensions; 12.13 Extending XSLT with JavaScript; 12.14 Adding Extension Functions Using Java; 12.15 Adding Extension Elements Using Java; 12.16 Using XSLT from Perl; 12.17 Using XSLT from Java; Chapter 13: Testing and Debugging; 13.1 Using xsl:message Effectively; 13.2 Tracing the Flow of Your Stylesheet Through Its Input Document; 13.3 Automating the Insertion of Debug Output; 13.4 Including Embedded Unit Test Data in Utility Stylesheets; 13.5 Structuring Unit Tests; 13.6 Testing Boundary and Error Conditions; Chapter 14: Generic and Functional Programming; 14.1 Introduction; 14.2 Creating Polymorphic XSLT; 14.3 Creating Generic Element Aggregation Functions; 14.4 Creating Generic Bounded Aggregation Functions; 14.5 Creating Generic Mapping Functions; 14.6 Creating Generic Node-Set Generators; Colophon;