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

Dangers of context item "."

When using context item in xsl:apply-templates never ending loops can easily occur. In this example the processing of stylesheet was interrupted by xsl:message instruction with terminate attribute equal "yes". The xsl:message sends its contents to the standard output and the terminate attribute can stop the processing (default value of this attribute is "no").

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="/aaa">
                  <xsl:apply-templates  select="bbb"/>
            </xsl:template>

            <xsl:template  match="bbb">
                  <xsl:param  name="i"
                              select="1"/>
                  <xsl:if  test="$i = 999">
                        <xsl:message  terminate="yes">
                              <xsl:text>FORCED STOP: $i=</xsl:text>
                              <xsl:value-of  select="$i"/>
                        </xsl:message>
                  </xsl:if>
                  <xsl:apply-templates  select=".">
                        <xsl:with-param  name="i"
                                    select="$i + 1"/>
                  </xsl:apply-templates>
            </xsl:template>

      </xsl:stylesheet>
XML

      <aaa>
            <bbb  x="000">B1</bbb>
            <bbb  x="111">B2</bbb>
            <bbb  x="222">B3</bbb>
            <bbb  x="333">B4</bbb>
      </aaa>
Output

Error:


-
FORCED STOP: $i=999 Processing terminated by xsl:message at line L


Previous chapter: Modes
Next chapter: Implicit behaviour
Previous page: Context item . and modes
Next page: Context item in XPath expressions

Kevin Carr

Natural Skin Care European Soaps
Scented Body Care Shea Body Butter
city of stanton
search engine optimization orange county internetusers


Also, you will want to check out Stanton California so you can see what's up and they are part of Stanton City Hall as well.

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

This is the guy we need in government office. His name is Kevin Carr City Of Stanton Council Candidate and he is a great guy. and we can get surf t shirts surfing shirt and And you must check out this website swim suit swimming suit and swim trunks