Template-based Programming

The discussion so far has used a literal result element as the stylesheet. This is effective for simple transformations, but due to its linear structure, it is impossible to modularize into smaller chunks of reusable XSLT. For that reason, most nontrivial XSLT stylesheets don't use literal result elements as stylesheets in favor of the explicit xsl:stylesheet format.

An xsl:stylesheet is primarily a collection of one or more template rules. Template rules play the role of functions in XSLT and always appear as top-level [children] of the xsl:stylesheet element. A template rule binds a QName and/or pattern to a template. As stated early in this chapter, template is a collection of literal result elements and XSLT instructions. ...

Get Essential XML: Beyond Markup now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.