Previous | Next | Indexes
adultinternetusers > Tutorials > XSLT 2.0 Tutorial > Templates - basic usage (12/12) >

Applying templates with lower priority - xsl:next-match

With element xsl:next-match matching templates with lower priority can be called from a matching template of higher priority.

In this example the template "*[1]" is used first for bbb element as it has explicit priority "1000". The next matching element is "bbb" and the last "*", so these three templates are applied in this order (with help of xsl:next-match). The ccc is matched with "ccc" template and then the "*" template is applied as in "bbb" case.

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">
                  <xxx>
                        <xsl:apply-templates  select="*"/>
                  </xxx>
            </xsl:template>

            <xsl:template  match="*">
                  <yyy>
                        <xsl:value-of  select="3*."/>
                  </yyy>
            </xsl:template>

            <xsl:template  match="*[1]"
                        priority="1000">
                  <zzz>
                        <xsl:next-match/>
                  </zzz>
            </xsl:template>

            <xsl:template  match="bbb">
                  <xsl:copy-of  select="."/>
                  <xsl:next-match/>
            </xsl:template>

            <xsl:template  match="ccc">
                  <ppp>
                        <xsl:next-match/>
                  </ppp>
            </xsl:template>

      </xsl:stylesheet>
XML

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

      <zzz>
            <xxx>
                  <zzz>
                        <bbb>12</bbb>
                        <yyy>36</yyy>
                  </zzz>
                  <ppp>
                        <yyy>36</yyy>
                  </ppp>
            </xxx>
      </zzz>


Previous chapter: - - -
Next chapter: Sequences
Previous page: Implicit priorities
Next page: - - -

Kevin Carr in Stanton

Natural Skin Care and European Soaps
Kevin Carr
Mayor Dave Shawver Stanton
Internetusers


You can also get Organic Skin Care products from Bliss Bath Body and you must check out their Natural Body Lotions and bath soaps

Now if you are looking for the best deals on surf clothing from Quiksilver and Roxy then you have to check these amazing deals here:

Hey, check out this Organic Skin Care European Soaps along with Natural Lavender Body Lotion and shea butter

and we can get surf t shirts surfing shirt and And you must check out this website swim suit swimming suit and swim trunks