Context-specific formatting (modes)

The problem with the examples above is that the formatting of the copied material is not affected by its move to a new location. In many examples, including the building of a table of contents, there is a need to apply different formatting to the material at its new location. For example, the chapter titles should be larger than the table of contents entries (as they are in this book).

XSLT includes the concept of 'modes'. Sets of templates can be assigned to specific modes, and the whole stylesheet can be switched between these modes to enable and disable templates that match the same element. The Mode attribute is added to the Template element to assign the template to a specific mode. In the following example, ...

Get XSL companion, The 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.