Changing the Template Set

Now we have an algorithm for selecting exactly which pattern matches, but what happens if the same elements must be processed in multiple contexts? This happens, for example, when dealing with cross references, automatic tables of contents, and multiple views of the same data.

Consider the following example:

Figure 7. modes.xml

<?xml version='1.0'?>
<chapter id="foo"><title>Chapter Title</title>

<para>This chapter is self-referential:
<xref linkend="foo"/>.</para>
</chapter>

And a stylesheet that produces:

Figure 8. modes.html

<h2>Chapter Title</h2>

<p>This chapter is self-referential:
<i>Chapter Title</i>.</p>



The chapter title must be processed twice, once to produce the title and once to produce the cross reference.

There is no dynamic mechanism for adjusting template priority, but there is a mechanism for selecting specific sets of templates. That mechanism is called "modes".