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

Mode: "#all"

Another predefined mode is the mode: "#all". Templates with mode attribute equal to this value are applied in all modes. This value can be used only for xsl:template elements, it is not applicable to xsl:apply-templates.

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:template>

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

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

            <xsl:template  match="ccc"
                        mode="#all">
                  <ccc-any/>
            </xsl:template>

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

      </xsl:stylesheet>
XML

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

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


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