cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tobia <tobia.confo...@linux.it>
Subject Re: limited number of loops with call-template?
Date Tue, 06 Nov 2007 14:18:12 GMT
Jens Reufsteck wrote:
> I'm using a template, which once called from outside starts calling
> itself as long as a certain condition is true. But after a certain
> amount of calls (1.100 times) it seems stopping to call itself.

I wouldn't write a template that calls itself recursively that many
times, unless I was sure that the implementation is tail-recursive and
that I am writing a tail-recursive template.

Said another way, try and traverse the document using matching (not
named) templates and apply-templates, along with modes if needed.

Based on your scarce snippet, you could try something like this:

  <xsl:template match="ebene">
    <xsl:if test="text() != preceding-sibling::ebene[1]/text()">
      <!-- we are looking at the first "ebene" of its kind:
           output all the "ebene" with that value inside a "baum" -->
      <baum ebene="{text()}">
        <xsl:apply-templates select="../ebene[text() = current()/text()]"
                             mode="output"/>
      </baum>
    </xsl:if>
  </xsl:template>

  <xsl:template match="ebene" mode="output">
    <ebene>
      ...
    </ebene>
  </xsl:template>

Of course, I don't have the slightest idea what baums and ebenes are, so
this is probably not what you need :-)


Tobia

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message