Priorities

Only one template can ever be selected by an XSLT processor to format a specific instance of an element. In the expressions shown in previous chapters, there is one template for each element type, but the introduction of context-specific templates means that a number of different templates may be applicable. The following two templates both apply to a Para element. The first template matches paragraphs within the introduction of a book. The second matches paragraphs within a Warning element. It can be imagined that, in some circumstances, there will be a warning within an introduction. In this case, both templates would be applicable:

<template match="introduction//para">...</template>
<template match="warning//para">...</template> ...

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.