Previous | Next | Indexes
adultinternetusers > Tutorials > XSLT 2.0 Tutorial > Recursions (2/6) >

Recursive xsl:apply-templates

Recursive structures are common in XSLT. In this example there is just one xsl:template with select equal to "*". But it achieves a lot, the program lists names of all elements in the source document.

Please note that the xsl:apply-templatesCalls the same xsl:template where it resides and so it is a typical recursive behavior.

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="*">
                  <xxx>
                        <xsl:value-of  select="name()"/>
                  </xxx>
                  <xsl:apply-templates  select="*"/>
            </xsl:template>

      </xsl:stylesheet>
XML

      <aaa>
            <bbb>
                  <ccc/>
                  <ddd/>
            </bbb>
            <eee>
                  <fff>
                        <ggg/>
                  </fff>
                  <hhh/>
            </eee>
      </aaa>
Output

      <xxx>aaa</xxx>
      <xxx>bbb</xxx>
      <xxx>ccc</xxx>
      <xxx>ddd</xxx>
      <xxx>eee</xxx>
      <xxx>fff</xxx>
      <xxx>ggg</xxx>
      <xxx>hhh</xxx>


Previous chapter: Keys
Next chapter: Date and Time
Previous page: Recursion
Next page: Recursive renaming of elements

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 ing suit and swim trunks