Previous | Next | Indexes
adultinternetusers > Tutorials > XSLT 2.0 Tutorial > Keys (9/12) >

Optional third argument of key() function

An optional third argument of key() function can be used to restrict the part of source Surf tree where the key looks for matches.

In this example the first usage of key() finds all ccc elements in the document with the value of "c" attribute equal 'X'. The second key() uses its third argument to restrict its scope to the node bbb with id='b2' and all its descendants.

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:key  name="kkk"
                        match="ccc"
                        use="@c"/>

            <xsl:template  match="/aaa">
                  <xxx>
                        <xsl:apply-templates  select="key('kkk','X')"/>
                  </xxx>
                  <yyy>
                        <xsl:apply-templates  select="key('kkk','X',bbb[@id='b2'])"/>
                  </yyy>
            </xsl:template>

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

      </xsl:stylesheet>
XML

      <aaa>
            <bbb  id="b1">
                  <ccc  c="X">1</ccc>
                  <ccc  c="Y">2</ccc>
            </bbb>
            <bbb  id="b2">
                  <ccc  c="X">3</ccc>
                  <ccc  c="Y">4</ccc>
            </bbb>
            <bbb  id="b3">
                  <ccc  c="X">5</ccc>
                  <ccc  c="Y">6</ccc>
            </bbb>
      </aaa>
Output

      <xxx>
            <ccc  c="X">1</ccc>
            <ccc  c="X">3</ccc>
            <ccc  c="X">5</ccc>
      </xxx>
      <yyy>
            <ccc  c="X">3</ccc>
      </yyy>


Previous chapter: Namespaces
Next chapter: Recursions
Previous page: Sequence of several values as the second argument of key function
Next page: Using keys in variables or parameters

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