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

Axes preceding-sibling and following-sibling

The "preceding-sibling::" axis of an element contains all elements which precedes the element in the document order and which share parent with the element.

The "following-sibling::" axis of an element contains all elements which follows the element in the document order and which share parent with the element.

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/ccc/ccc-b/ccc-b-3/preceding-sibling::*"/>
                  </xxx>
                  <yyy>
                        <xsl:apply-templates  select="/aaa/ccc/ccc-b/ccc-b-3/following-sibling::*"/>
                  </yyy>
            </xsl:template>

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

      </xsl:stylesheet>
XML

      <aaa>
            <bbb>
                  <bbb-a/>
                  <bbb-b/>
            </bbb>
            <ccc>
                  <ccc-a/>
                  <ccc-b>
                        <ccc-b-1/>
                        <ccc-b-2/>
                        <ccc-b-3/>
                        <ccc-b-4/>
                        <ccc-b-5/>
                  </ccc-b>
                  <ccc-c/>
            </ccc>
            <ddd>
                  <ddd-a/>
                  <ddd-b/>
            </ddd>
      </aaa>
Output

      <xxx>
            <zzz  name="ccc-b-1"
                        position="1"/>
            <zzz  name="ccc-b-2"
                        position="2"/>
      </xxx>
      <yyy>
            <zzz  name="ccc-b-4"
                        position="1"/>
            <zzz  name="ccc-b-5"
                        position="2"/>
      </yyy>


Previous chapter: Sorting
Next chapter: Named-Templates
Previous page: Axes preceding and following
Next page: Attribute 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