RE: [xsl] Number of times apply-templates gets executed.

Subject: RE: [xsl] Number of times apply-templates gets executed.
From: "Passin, Tom" <tpassin@xxxxxxxxxxxx>
Date: Tue, 7 Jan 2003 11:20:47 -0500
[ Patel, Viral]

> I am new to XSL and I have several questions - some of them 
> might be really easy ones but I just want to confirm. 1. I 
> believe its not possible to change the value of 
> <xsl:variable> once its set - correct?
> 
Correct.

> 2. Is there a way to figure out how many times a template was 
> applied when using <xsl:apply-templates>?
> 
> 3. Is there an easy to implement a counter or a boolean in 
> xsl? If yes then how? Implementing either one would be fine.
> 

It will be better if you talk about what you want to accomplish rather
than procedural steps that you imagine you might want to use.  For
example, literally there are boolean values in xslt, but it sounds like
you might want to set a flag and carry it along.  This is not a matter
have whether you can "have a boolean".  You can do this kind of thing by
passing parameters to templates, but it is likely that some other
approach will be easier and more understandable.

As for counters, in xslt you generally select sets of nodes and then
operate on them.  If you leave them in document order (as is usually the
case), then the position of the current node in that node set (given by
the position() function) may do the job you wre thinking that a counter
would.  It all depends on what you want to do.

Cheers,

Tom P

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread