Home Page Icon
Home Page
Table of Contents for
XSLT Cookbook
Close
XSLT Cookbook
by Sal Mangano
XSLT Cookbook
XSLT Cookbook
Preface
Structure of This Book
Conventions Used in This Book
How to Contact Us
Acknowledgments
1. Strings
Testing if a String Ends with Another String
Problem
Solution
Discussion
Finding the Position of a Substring
Problem
Solution
Discussion
Removing Specific Characters from a String
Problem
Solution
Discussion
Finding Substrings from the End of a String
Problem
Solution
Discussion
Duplicating a String N Times
Problem
Solution
Discussion
See Also
Reversing a String
Problem
Solution
Discussion
Replacing Text
Problem
Solution
Discussion
Converting Case
Problem
Solution
Discussion
See Also
Tokenizing a String
Problem
Solution
Discussion
See Also
Making Do Without Regular Expressions
Problem
Solution
Discussion
Using the EXSLT String Extensions
Problem
Solution
Discussion
2. Numbers and Math
Formatting Numbers
Problem
Solution
Use xsl:decimal-format in conjunction with format-number( )
Use xsl:number
Discussion
Formatting numbers into columns using a fixed number of decimal places
Formatting money like U.S. accountants
Formatting numbers for many European countries
Converting numbers to Roman numerals
Creating column numbers like a spreadsheet
Formatting numbers using Arabic characters
Rounding Numbers to a Specified Precision
Problem
Solution
Discussion
Converting from Roman Numerals to Numbers
Problem
Solution
Discussion
Converting from One Base to Another
Problem
Solution
Discussion
Implementing Common Math Functions
Problem
Solution
Absolute value: math:abs(x)
Square root: math:sqrt(x)
Logarithms: math:log10(number), math:log(number), and math:logN(x,base)
Power: math:power(base,power)
Factorial
Discussion
Computing Sums and Products
Problem
Solution
Discussion
See Also
Finding Minimums and Maximums
Problem
Solution
Discussion
Computing Statistical Functions
Problem
Solution
Discussion
Computing Combinatorial Functions
Problem
Solution
Discussion
Testing Bits
Problem
Solution
Discussion
3. Dates and Times
Introduction
See Also
Calculating the Day of the Week
Problem
Solution
Discussion
Determining the Last Day of the Month
Problem
Solution
Discussion
See Also
Getting Names for Days and Months
Problem
Solution
Discussion
Calculating Julian and Absolute Day Numbers from a Specified Date
Problem
Solution
Discussion
Calculating the Week Number for a Specified Date
Problem
Solution
Discussion
See Also
Working with the Julian Calendar
Problem
Solution
Discussion
Working with the ISO Calendar
Problem
Solution
Discussion
See Also
Working with the Islamic Calendar
Problem
Solution
Discussion
See Also
Working with the Hebrew Calendar
Problem
Solution
Discussion
Formatting Dates and Times
Problem
Solution
Discussion
Determining Secular and Religious Holidays
Problem
Solution
Discussion
4. Selecting and Traversing
Optimizing Node Selections
Problem
Solution
Avoid unnecessary reliance on default processing rules
Avoid using the descendant, descendant-or-self, preceding, or following axes when they aren’t necessary
Prefer “selecting” and “matching” over “filtering”
Cache frequently used node sets in variables
Use xsl:key if nodes are frequently selected by static criteria
Discussion
Avoid unnecessarily reliance on default processing rules
Prefer “selecting” and “matching” over “filtering”
Cache frequently used node sets in variables
Use xsl:key if nodes will be selected by static criteria frequently
Determining if Two Nodes Are the Same
Problem
Solution
Discussion
See Also
Ignoring Duplicate Elements
Problem
Solution
Discussion
See Also
Selecting All but a Specific Element
Problem
Solution
Discussion
See Also
Performing a Preorder Traversal
Problem
Solution
Discussion
Performing a Postorder Traversal
Problem
Solution
Discussion
Performing an In-Order Traversal
Problem
Solution
Discussion
Performing a Level-Order Traversal
Problem
Solution
Discussion
Processing Nodes by Position
Problem
Solution
Discussion
See Also
5. XML to Text
Dealing with Whitespace
Problem
Solution
Too much whitespace
Too little whitespace
Discussion
See Also
Exporting XML to Delimited Data
Problem
Solution
Create a CSV file from flat attribute-encoded elements
Create a CSV file from flat element-encoded data
Handle more complex mappings
Discussion
Creating a Columnar Report
Problem
Solution
Discussion
Displaying a Hierarchy
Problem
Solution
Discussion
Numbering Textual Output
Problem
Solution
Number siblings sequentially
Start from a number other than one
Number elements globally
Number elements globally within a subcontext
Number hierarchically
Discussion
Wrapping Text to a Specified Width and Alignment
Problem
Solution
Discussion
See Also
6. XML to XML
Converting Attributes to Elements
Problem
Solution
Discussion
Converting Elements to Attributes
Problem
Solution
Discussion
Renaming Elements or Attributes
Problem
Solution
Discussion
Merging Documents with Identical Schema
Problem
Solution
Discussion
Merging Documents with Unlike Schema
Problem
Solution
Incorporate one document as a subpart of a parent document
Weave two documents together
Join elements from two documents to make new elements
Discussion
See Also
Splitting Documents
Problem
Solution
Discussion
See Also
Flattening an XML Hierarchy
Problem
Solution
Discussion
Deepening an XML Hierarchy
Problem
Solution
Add structure based on existing data
Add structure to correct a poorly designed document
Discussion
Add structure based on existing data
Add structure to correct a poorly designed document
Reorganizing an XML Hierarchy
Problem
Solution
Discussion
7. Querying XML
Performing Set Operations on Node Sets
Problem
Solution
Discussion
See Also
Performing Set Operations on Node Sets Using Value Semantics
Problem
Solution
Discussion
Determining Set Equality by Value
Problem
Solution
Discussion
Performing Structure-Preserving Queries
Problem
Solution
Discussion
Joins
Problem
Solution
Discussion
Implementing the W3C XML Query-Use Cases in XSLT
Problem
Solution
Discussion
8. XML to HTML
Using XSLT as a Styling Language
Problem
Solution
Discussion
See Also
Creating Hyperlinked Documents
Problem
Solution
Discussion
See Also
Creating HTML Tables
Problem
Solution
Discussion
Creating Frames
Problem
Solution
Discussion
See Also
Creating Data-Driven Stylesheets
Problem
Solution
Discussion
Creating a Self-Contained HTML Transformation
Problem
Solution
Discussion
Populating a Form
Problem
Solution
Discussion
See Also
9. XML to SVG
Transforming an Existing Boilerplate SVG
Problem
Solution
Discussion
Creating Reusable SVG Generation Utilities for Graphs and Charts
Problem
Solution
Axis generation
Bar generation
XY plots
Pie-slice generation
Open-Hi-Lo-Close plots
Discussion
Creating a Tree Diagram
Problem
Solution
Discussion
See Also
Creating Interactive SVG-Enabled Web Pages
Problem
Solution
Discussion
See Also
10. Code Generation
Generating Constant Definitions
Problem
Solution
Discussion
Generating Switching Code
Problem
Solution
Discussion
Generating Message-Handling Stub Code
Problem
Solution
Discussion
Generating Data Wrappers
Problem
Solution
Discussion
Generating Pretty Printers
Problem
Solution
Discussion
Generating a Test Data-Entry Web Client
Problem
Solution
Discussion
Generating Test-Entry Web CGI
Problem
Solution
Discussion
Generating Code from UML Models via XMI
Problem
Solution
Discussion
Generating XSLT from XSLT
Problem
Solution
Discussion
See Also
11. Vertical XSLT Application Recipes
Converting Visio VDX Documents to SVG
Problem
Solution
Discussion
See Also
Working with Excel XML Spreadsheets
Problem
Solution
Discussion
Generating XTM Topic Maps from UML Models via XMI
Problem
Solution
Discussion
See Also
Generating Web Sites from XTM Topic Maps
Problem
Solution
Sorting algorithms
Programming languages
Root topic
Page elements and layout
Discussion
See Also
Serving SOAP Documentation from WSDL
Problem
Solution
Discussion
See Also
12. Extending and Embedding XSLT
Saxon Extension Functions
Saxon Extension Elements
Xalan Java 2 Extension Functions
Java Extension Function Using the Class Format Namespace
Java Extension Function Using the Package Format Namespace
Java Extension Function Using the Java Format Namespace
Scripting Extension Function Using Inline Script Code
Xalan Java 2 Extension Elements
Java Extension Element
Scripting Extension Elements
MSXML Extension Functions
See Also
Using Saxon’s and Xalan’s Native Extensions
Problem
Solution
You want to output to more than one destination
You want to split a complex transformation into a series of transformations in a pipeline
You want to work with dates and times
You need a more efficient implementation of set operations
You want extended information about a node in the source tree
You want to interact with a relational database
You want to dynamically evaluate an XPath expression created at runtime
You want to change the value of a variable
You want to write first-class extension functions in XSLT
Discussion
See Also
Extending XSLT with JavaScript
Problem
Solution
Discussion
See Also
Adding Extension Functions Using Java
Problem
Solution
Discussion
See Also
Adding Extension Elements Using Java
Problem
Solution
Discussion
See Also
Using XSLT from Perl
Problem
Solution
Discussion
See Also
Using XSLT from Java
Problem
Solution
Discussion
See Also
13. Testing and Debugging
Using xsl:message Effectively
Problem
Solution
Discussion
Tracing the Flow of Your Stylesheet Through Its Input Document
Problem
Solution
Discussion
See Also
Automating the Insertion of Debug Output
Problem
Solution
Discussion
See Also
Including Embedded Unit Test Data in Utility Stylesheets
Problem
Solution
Discussion
Structuring Unit Tests
Problem
Solution
Discussion
See Also
Testing Boundary and Error Conditions
Problem
Solution
Boundary-condition testing
Error-condition testing
Discussion
14. Generic and Functional Programming
Introduction
Extending the Content of Global Variables
Using Template Tags
See Also
Creating Polymorphic XSLT
Problem
Solution
Discussion
See Also
Creating Generic Element Aggregation Functions
Problem
Solution
Discussion
See Also
Creating Generic Bounded Aggregation Functions
Problem
Solution
Discussion
Creating Generic Mapping Functions
Problem
Solution
Discussion
Creating Generic Node-Set Generators
Problem
Solution
Discussion
Index
Colophon
Search in book...
Toggle Font Controls
Playlists
Add To
Create new playlist
Name your new playlist
Playlist description (optional)
Cancel
Create playlist
Sign In
Email address
Password
Forgot Password?
Create account
Login
or
Continue with Facebook
Continue with Google
Sign Up
Full Name
Email address
Confirm Email Address
Password
Login
Create account
or
Continue with Facebook
Continue with Google
Prev
Previous Chapter
Cover
Next
Next Chapter
Preface
XSLT Cookbook
Sal Mangano
Editor
Simon St. Laurent
Copyright © 2002 O'Reilly Media, Inc.
Add Highlight
No Comment
..................Content has been hidden....................
You can't read the all page of ebook, please click
here
login for view all page.
Day Mode
Cloud Mode
Night Mode
Reset