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

Selection of all child elements or all attributes of an element

If star "*" is used instead of element names, all names of elements are matched. Similarly, "@*" matches all attribute nodes.

Function name() returns name of currently processed elements or attributes.

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

            <xsl:template  match="*">
                  <z1>
                        <xsl:value-of  select="name()"/>
                        <xsl:text>: </xsl:text>
                        <xsl:value-of  select="."/>
                  </z1>
            </xsl:template>

            <xsl:template  match="@*">
                  <z2>
                        <xsl:value-of  select="name()"/>
                        <xsl:text>: </xsl:text>
                        <xsl:value-of  select="."/>
                  </z2>
            </xsl:template>

      </xsl:stylesheet>
XML

      <aaa  p="1"
                  r="2"
                  s="3">
            <bbb>B</bbb>
            <ccc>C</ccc>
            <ddd>D</ddd>
      </aaa>
Output

      <xxx>
            <z1>bbb: B</z1>
            <z1>ccc: C</z1>
            <z1>ddd: D</z1>
      </xxx>
      <yyy>
            <z2>p: 1</z2>
            <z2>r: 2</z2>
            <z2>s: 3</z2>
      </yyy>


Previous chapter: - - -
Next chapter: Sequences
Previous page: Shared templates for several elements
Next page: Template priorities

Kevin Carr in Stanton

Natural Skin Care and European Soaps
Kevin Carr
City of 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