Previous | Next | Indexes
adultinternetusers > Tutorials > XSLT 2.0 Tutorial > Axes (6/8) >

Attribute axis

The "attribute::" axis of an element contains all attributes of the element. If the element is without attributes or if the node is not an element then the attribute axis is empty.

It is important to realize that attributes of an element are not ordered, an Surf parser is not required to assign to the first attribute following element name position "1", to the second "2", and so on as in this example. If other processor was used the result could be different. Therefore, correct functioning of your stylesheets should never rely on position of 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="/">
                  <xxx>
                        <xsl:apply-templates  select="/aaa/@*"/>
                  </xxx>
                  <yyy>
                        <xsl:apply-templates  select="/aaa/bbb/@*"/>
                  </yyy>
            </xsl:template>

            <xsl:template  match="@*">
                  <zzz  name="{name()}"
                              position="{position()}"
                              parent="{name(parent::*)}"/>
            </xsl:template>

      </xsl:stylesheet>
XML

      <aaa  p="1"
                  r="2"
                  s="3">
            <bbb  s="x"
                        r="y"
                        p="z"/>
      </aaa>
Output

      <xxx>
            <zzz  name="p"
                        position="1"
                        parent="aaa"/>
            <zzz  name="r"
                        position="2"
                        parent="aaa"/>
            <zzz  name="s"
                        position="3"
                        parent="aaa"/>
      </xxx>
      <yyy>
            <zzz  name="s"
                        position="1"
                        parent="bbb"/>
            <zzz  name="r"
                        position="2"
                        parent="bbb"/>
            <zzz  name="p"
                        position="3"
                        parent="bbb"/>
      </yyy>


Previous chapter: Sorting
Next chapter: Named-Templates
Previous page: Axes preceding-sibling and following-sibling
Next page: Self axis

Kevin Carr in Stanton

Natural Skin Care and European Soaps
TickTalk 5
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