<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

  <!-- FileName: MODES10 -->
  <!-- Document: http://www.w3.org/TR/xslt -->
  <!-- DocVersion: 19991116 -->
  <!-- Section: 5.7 Modes -->
  <!-- Creator: David Marston -->
  <!-- Purpose: Show that we only go into a mode via apply-templates.
     You can't put a mode on call-template, and the fact that you call a named
     template that has a mode specifier doesn't mean you are in that mode. -->

<xsl:template match="/"><tracexsl:text xmlns:tracexsl="http://www.w3.org/1999/XSL/Transform" xml:space="preserve">
</tracexsl:text><tracexsl:comment xmlns:tracexsl="http://www.w3.org/1999/XSL/Transform">[TraceXSL Begin] match="/"</tracexsl:comment><tracexsl:text xmlns:tracexsl="http://www.w3.org/1999/XSL/Transform" xml:space="preserve">
</tracexsl:text>
  <out>
    <tracexsl:text xmlns:tracexsl="http://www.w3.org/1999/XSL/Transform" xml:space="preserve">
</tracexsl:text><tracexsl:comment xmlns:tracexsl="http://www.w3.org/1999/XSL/Transform">[TraceXSL] APPLY MODE="a"</tracexsl:comment><tracexsl:text xmlns:tracexsl="http://www.w3.org/1999/XSL/Transform" xml:space="preserve">
</tracexsl:text><xsl:apply-templates select="doc" mode="a"/><tracexsl:text xmlns:tracexsl="http://www.w3.org/1999/XSL/Transform" xml:space="preserve">
</tracexsl:text><tracexsl:comment xmlns:tracexsl="http://www.w3.org/1999/XSL/Transform">[TraceXSL] END MODE="a"</tracexsl:comment><tracexsl:text xmlns:tracexsl="http://www.w3.org/1999/XSL/Transform" xml:space="preserve">
</tracexsl:text>
  </out>
<tracexsl:text xmlns:tracexsl="http://www.w3.org/1999/XSL/Transform" xml:space="preserve">
</tracexsl:text><tracexsl:comment xmlns:tracexsl="http://www.w3.org/1999/XSL/Transform">[TraceXSL END] match="/"</tracexsl:comment><tracexsl:text xmlns:tracexsl="http://www.w3.org/1999/XSL/Transform" xml:space="preserve">
</tracexsl:text></xsl:template>

<xsl:template match="doc" mode="a" priority="3"><tracexsl:text xmlns:tracexsl="http://www.w3.org/1999/XSL/Transform" xml:space="preserve">
</tracexsl:text><tracexsl:comment xmlns:tracexsl="http://www.w3.org/1999/XSL/Transform">[TraceXSL Begin] match="doc" mode="a"</tracexsl:comment><tracexsl:text xmlns:tracexsl="http://www.w3.org/1999/XSL/Transform" xml:space="preserve">
</tracexsl:text>
  <xsl:text>Found doc...</xsl:text>
  <tracexsl:text xmlns:tracexsl="http://www.w3.org/1999/XSL/Transform" xml:space="preserve">
</tracexsl:text><tracexsl:comment xmlns:tracexsl="http://www.w3.org/1999/XSL/Transform">[TraceXSL] CALL NAME="scan"</tracexsl:comment><tracexsl:text xmlns:tracexsl="http://www.w3.org/1999/XSL/Transform" xml:space="preserve">
</tracexsl:text><xsl:call-template name="scan"/>
<tracexsl:text xmlns:tracexsl="http://www.w3.org/1999/XSL/Transform" xml:space="preserve">
</tracexsl:text><tracexsl:comment xmlns:tracexsl="http://www.w3.org/1999/XSL/Transform">[TraceXSL END] match="doc" mode="a"</tracexsl:comment><tracexsl:text xmlns:tracexsl="http://www.w3.org/1999/XSL/Transform" xml:space="preserve">
</tracexsl:text></xsl:template>

<!-- The following template is both applied in mode a and called -->
<xsl:template name="scan" match="*" mode="a" priority="2"><tracexsl:text xmlns:tracexsl="http://www.w3.org/1999/XSL/Transform" xml:space="preserve">
</tracexsl:text><tracexsl:comment xmlns:tracexsl="http://www.w3.org/1999/XSL/Transform">[TraceXSL Begin] match="*" name="scan" mode="a"</tracexsl:comment><tracexsl:text xmlns:tracexsl="http://www.w3.org/1999/XSL/Transform" xml:space="preserve">
</tracexsl:text>
  <xsl:text>Scanned </xsl:text><xsl:value-of select="name(.)"/><xsl:text>
</xsl:text>
  <xsl:apply-templates/>
<tracexsl:text xmlns:tracexsl="http://www.w3.org/1999/XSL/Transform" xml:space="preserve">
</tracexsl:text><tracexsl:comment xmlns:tracexsl="http://www.w3.org/1999/XSL/Transform">[TraceXSL END] match="*" name="scan" mode="a"</tracexsl:comment><tracexsl:text xmlns:tracexsl="http://www.w3.org/1999/XSL/Transform" xml:space="preserve">
</tracexsl:text></xsl:template>

<xsl:template match="x" priority="4"><tracexsl:text xmlns:tracexsl="http://www.w3.org/1999/XSL/Transform" xml:space="preserve">
</tracexsl:text><tracexsl:comment xmlns:tracexsl="http://www.w3.org/1999/XSL/Transform">[TraceXSL Begin] match="x"</tracexsl:comment><tracexsl:text xmlns:tracexsl="http://www.w3.org/1999/XSL/Transform" xml:space="preserve">
</tracexsl:text>
  <xsl:text>Found x, no mode: </xsl:text><xsl:value-of select="."/><xsl:text>
</xsl:text>
  <tracexsl:text xmlns:tracexsl="http://www.w3.org/1999/XSL/Transform" xml:space="preserve">
</tracexsl:text><tracexsl:comment xmlns:tracexsl="http://www.w3.org/1999/XSL/Transform">[TraceXSL] APPLY MODE="a"</tracexsl:comment><tracexsl:text xmlns:tracexsl="http://www.w3.org/1999/XSL/Transform" xml:space="preserve">
</tracexsl:text><xsl:apply-templates mode="a"/><tracexsl:text xmlns:tracexsl="http://www.w3.org/1999/XSL/Transform" xml:space="preserve">
</tracexsl:text><tracexsl:comment xmlns:tracexsl="http://www.w3.org/1999/XSL/Transform">[TraceXSL] END MODE="a"</tracexsl:comment><tracexsl:text xmlns:tracexsl="http://www.w3.org/1999/XSL/Transform" xml:space="preserve">
</tracexsl:text>
<tracexsl:text xmlns:tracexsl="http://www.w3.org/1999/XSL/Transform" xml:space="preserve">
</tracexsl:text><tracexsl:comment xmlns:tracexsl="http://www.w3.org/1999/XSL/Transform">[TraceXSL END] match="x"</tracexsl:comment><tracexsl:text xmlns:tracexsl="http://www.w3.org/1999/XSL/Transform" xml:space="preserve">
</tracexsl:text></xsl:template>

<xsl:template match="x" mode="a" priority="4"><tracexsl:text xmlns:tracexsl="http://www.w3.org/1999/XSL/Transform" xml:space="preserve">
</tracexsl:text><tracexsl:comment xmlns:tracexsl="http://www.w3.org/1999/XSL/Transform">[TraceXSL Begin] match="x" mode="a"</tracexsl:comment><tracexsl:text xmlns:tracexsl="http://www.w3.org/1999/XSL/Transform" xml:space="preserve">
</tracexsl:text>
  <xsl:text>Found x, mode a: </xsl:text><xsl:value-of select="@test"/><xsl:text>
</xsl:text>
<tracexsl:text xmlns:tracexsl="http://www.w3.org/1999/XSL/Transform" xml:space="preserve">
</tracexsl:text><tracexsl:comment xmlns:tracexsl="http://www.w3.org/1999/XSL/Transform">[TraceXSL END] match="x" mode="a"</tracexsl:comment><tracexsl:text xmlns:tracexsl="http://www.w3.org/1999/XSL/Transform" xml:space="preserve">
</tracexsl:text></xsl:template>

<xsl:template match="text()"><tracexsl:text xmlns:tracexsl="http://www.w3.org/1999/XSL/Transform" xml:space="preserve">
</tracexsl:text><tracexsl:comment xmlns:tracexsl="http://www.w3.org/1999/XSL/Transform">[TraceXSL Begin] match="text()"</tracexsl:comment><tracexsl:text xmlns:tracexsl="http://www.w3.org/1999/XSL/Transform" xml:space="preserve">
</tracexsl:text>
  <xsl:text>modeless text: </xsl:text><xsl:value-of select="."/><xsl:text>
</xsl:text>
<tracexsl:text xmlns:tracexsl="http://www.w3.org/1999/XSL/Transform" xml:space="preserve">
</tracexsl:text><tracexsl:comment xmlns:tracexsl="http://www.w3.org/1999/XSL/Transform">[TraceXSL END] match="text()"</tracexsl:comment><tracexsl:text xmlns:tracexsl="http://www.w3.org/1999/XSL/Transform" xml:space="preserve">
</tracexsl:text></xsl:template>

<xsl:template match="text()" mode="a"><tracexsl:text xmlns:tracexsl="http://www.w3.org/1999/XSL/Transform" xml:space="preserve">
</tracexsl:text><tracexsl:comment xmlns:tracexsl="http://www.w3.org/1999/XSL/Transform">[TraceXSL Begin] match="text()" mode="a"</tracexsl:comment><tracexsl:text xmlns:tracexsl="http://www.w3.org/1999/XSL/Transform" xml:space="preserve">
</tracexsl:text>
  <xsl:text>mode a text: </xsl:text><xsl:value-of select="."/>
<tracexsl:text xmlns:tracexsl="http://www.w3.org/1999/XSL/Transform" xml:space="preserve">
</tracexsl:text><tracexsl:comment xmlns:tracexsl="http://www.w3.org/1999/XSL/Transform">[TraceXSL END] match="text()" mode="a"</tracexsl:comment><tracexsl:text xmlns:tracexsl="http://www.w3.org/1999/XSL/Transform" xml:space="preserve">
</tracexsl:text></xsl:template>

</xsl:stylesheet>