Modes Example

Figure 11. modes.xsl

<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                version="1.0">

<xsl:output method="html"/>

<xsl:template match="chapter/title">
  <h2><xsl:apply-templates/></h2>
</xsl:template>

<xsl:template match="chapter/title" mode="crossref">
  <i><xsl:apply-templates/></i>
</xsl:template>

<xsl:template match="xref">
  <xsl:variable name="linkend" select="@linkend"/>
  <xsl:apply-templates select="//*[@id=$linkend]/title"
                       mode="crossref"/>
</xsl:template>

<xsl:template match="para">
  <p><xsl:apply-templates/></p>
</xsl:template>

<xsl:template match="emphasis">
  <i><xsl:apply-templates/></i>
</xsl:template>

</xsl:stylesheet>



Figure 12. modes.html

<h2>Chapter Title</h2>

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