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

Child and parent axes

Axes in XPath expressions define "direction of movement" in the source document. The axes names are followed by "::" in XPath expressions.

The "child::" axis is the most commonly used axis in XPath expressions. It is the default axis and so it is not usually explicitly given. The child axis of an element contains all children of this element.

The xxx example compares if two nodes are equal. On the left side the "child::" axis is explicitly given on the right side the axis is not specified and so default axis is used.

The "parent::" axis reverses the direction of child axis. A node cannot have more than one parent. In the yyy example the expression at first descends to bbb element and then returns to its parent aaa.

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="/child::aaa/child::bbb is /aaa/bbb"/>
                  </xxx>
                  <yyy>
                        <xsl:value-of  select="/aaa/bbb/parent::aaa is aaa"/>
                  </yyy>
            </xsl:template>

      </xsl:stylesheet>
XML

      <aaa>
            <bbb/>
      </aaa>
Output

      <xxx>true</xxx>
      <yyy>true</yyy>


Previous chapter: Sorting
Next chapter: Named-Templates
Previous page: Steps
Next page: Descendant and ancestor axes

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