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

Template priorities

It may happen that for a single element in the source document there are several matching templates in the XSLT stylesheet. Attribute priority on the xsl:template element can be explicitly used to distinguish which one should be used based on numeric value of the attribute.

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

            <xsl:template  match="aaa"
                        priority="1000">
                  <xxx>
                        <xsl:apply-templates  select="*"/>
                  </xxx>
            </xsl:template>

            <xsl:template  match="*"
                        priority="1">
                  <p1>
                        <xsl:value-of  select="."/>
                  </p1>
            </xsl:template>

            <xsl:template  match="bbb"
                        priority="22">
                  <p22>
                        <xsl:value-of  select="."/>
                  </p22>
            </xsl:template>

            <xsl:template  match="bbb[2]"
                        priority="333">
                  <p333>
                        <xsl:value-of  select="."/>
                  </p333>
            </xsl:template>

      </xsl:stylesheet>
XML

      <aaa>
            <bbb>B1</bbb>
            <bbb>B2</bbb>
            <ccc>C</ccc>
            <ddd>D</ddd>
      </aaa>
Output

      <xxx>
            <p22>B1</p22>
            <p333>B2</p333>
            <p1>C</p1>
            <p1>D</p1>
      </xxx>


Previous chapter: - - -
Next chapter: Sequences
Previous page: Selection of all child elements or all attributes of an element
Next page: Implicit priorities

Kevin Carr

Natural Skin Care European Soaps
Scented Body Care Shea Body Butter
city of stanton
search engine optimization orange county internetusers


Also, you will want to check out Stanton California so you can see what's up and they are part of Stanton City Hall as well.

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

This is the guy we need in government office. His name is Kevin Carr City Of Stanton Council Candidate and he is a great guy. and we can get surf t shirts surfing shirt and And you must check out this website swim suit swimming suit and swim trunks