Chapter 8. Working with Variables

  • <xsl:variable>

  • <xsl:param>

  • <xsl:with-param>

XSLT provides the functionality to create special values that can be declared and used by expressions in other elements in the stylesheet. These values are attached, or bound, to named objects called variables. A variable in XSLT can be either global (available throughout the stylesheet) or local (available only to the element where it is declared), and it must be declared before it can be used.

In this chapter, we will discuss the two ways to declare variables in XSLT, using either <xsl:variable> or <xsl:param>, and the process of calling, or referencing, variable values. We will also discuss <xsl:with-param>, which allows a template to override the value of a variable ...

Get XSLT and XPATH: A Guide to XML Transformations 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.