Previous | Next | Indexes
adultinternetusers > Tutorials > XSLT 2.0 Tutorial > Context (1/6) >

Focus of XPath expressions

Focus of an expression consist of its context item, context position, and context size

The context item is the item currently being processed and its returned by single dot: ".".

The context position is the position of the context item within the sequence of items currently being processed. It is returned by the function position().

The context size is the number of items in the sequence of items currently being processed. It is returned by the function last().

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="*">
                  <N  context-item="{name(.)}"
                              context-position="{position()}"
                              context-size="{last()}">
                        <xsl:copy-of  select="*"/>
                  </N>
                  <xsl:apply-templates  select="*"/>
            </xsl:template>

      </xsl:stylesheet>
XML

      <aaa>
            <bbb>
                  <ccc/>
                  <ddd/>
            </bbb>
            <xxx>
                  <yyy/>
            </xxx>
      </aaa>
Output

      <N  context-item="aaa"
                  context-position="1"
                  context-size="1">
            <bbb>
                  <ccc/>
                  <ddd/>
            </bbb>
            <xxx>
                  <yyy/>
            </xxx>
      </N>
      <N  context-item="bbb"
                  context-position="1"
                  context-size="2">
            <ccc/>
            <ddd/>
      </N>
      <N  context-item="ccc"
                  context-position="1"
                  context-size="2"/>
      <N  context-item="ddd"
                  context-position="2"
                  context-size="2"/>
      <N  context-item="xxx"
                  context-position="2"
                  context-size="2">
            <yyy/>
      </N>
      <N  context-item="yyy"
                  context-position="1"
                  context-size="1"/>


Previous chapter: Modes
Next chapter: Implicit behaviour
Previous page: - - -
Next page: Context item. and modes

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