Previous | Next | Indexes
Zvon > Tutorials > XSLT 2.0 Tutorial > Modes (6/7) >

Mode: "#current"

The third predefined mode is "#current". It can be used for xsl:apply-templates elements. It sets the mode of this instruction to the mode of xsl:template where it appears.

XSLT

      <xsl:stylesheet
                  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                  version="2.0">
            <xsl:output  method="xml"
                        indent="yes"
                        omit-xml-declaration="yes"/>

            <xsl:template  match="/aaa">
                  <xsl:apply-templates/>
                  <xsl:apply-templates  mode="m1"/>
                  <xsl:apply-templates  mode="m2"/>
            </xsl:template>

            <xsl:template  match="bbb">
                  <bbb-default>
                        <xsl:apply-templates  select="ccc"
                                    mode="#current"/>
                  </bbb-default>
            </xsl:template>

            <xsl:template  match="bbb"
                        mode="m1">
                  <bbb-1>
                        <xsl:apply-templates  select="ccc"
                                    mode="#current"/>
                  </bbb-1>
            </xsl:template>

            <xsl:template  match="bbb"
                        mode="m2">
                  <bbb-2>
                        <xsl:apply-templates  select="ccc"
                                    mode="#current"/>
                  </bbb-2>
            </xsl:template>

            <xsl:template  match="ccc">
                  <ccc-default/>
            </xsl:template>

            <xsl:template  match="ccc"
                        mode="m1">
                  <ccc-1/>
            </xsl:template>

            <xsl:template  match="ccc"
                        mode="m2">
                  <ccc-2/>
            </xsl:template>

      </xsl:stylesheet>
XML

      <aaa>
            <bbb>
                  <ccc/>
            </bbb>
      </aaa>
Output

      <bbb-default>
            <ccc-default/>
      </bbb-default>
      <bbb-1>
            <ccc-1/>
      </bbb-1>
      <bbb-2>
            <ccc-2/>
      </bbb-2>


Previous chapter: Value-of
Next chapter: Context
Previous page: Mode: #all
Next page: Mode #current in shared modes