Subject: RE: Number of times apply-templates gets executed.
From: "Martinez, Brian" <brian.martinez@xxxxxxxx>
Date: Tue, 7 Jan 2003 09:36:27 -0700
|
> From: Patel, Viral [mailto:viral.patel@xxxxxxxxxxxxxxxxxxxx]
> Sent: Tuesday, January 07, 2003 8:55 AM
> Subject: Number of times apply-templates gets executed.
>
> Hi,
>
> 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>?
Not in a procedural sense (incrementing a loop counter, for instance), but
there's other ways you could determine this.
Output the count of nodes matching your template rule:
<xsl:value-of select="count(/document/book/pages)"/>
Or output the position of the node being processed by a matching template:
<current-node><xsl:value-of select="position()"/></current-node>
Note that this will be the position of the *output* nodes--after any sorting
is done--not the order of nodes in the source document. But it will still
tell you how many times the template was invoked.
> 3. Is there an easy to implement a counter or a boolean in
> xsl? If yes then
> how? Implementing either one would be fine.
Not for a loop counter, but you're also looking at your problem from a
procedural rather than a functional perspective. When you build a result
tree from your input, there should be no need for a loop counter--you simply
provide templates that match the nodes you want to process, and output them
in the format you want.
As far as booleans go, they exist in XSLT--but they're not needed to control
loops or for other procedural logic. Your processing can be controlled
entirely by iteration using xsl:for-each or by rules-based templates.
cheers,
b.
| brian martinez brian.martinez@xxxxxxxx |
| senior gui programmer 303.708.7248 |
| trip network, inc. fax 303.790.9350 |
| 6436 s. racine cir. englewood, co 80111 |
| http://www.cheaptickets.com/ http://www.trip.com/ |
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
- Re: Number of times apply-templates gets executed., (continued)
- G. Ken Holman - Tue, 7 Jan 2003 11:07:55 -0500 (EST)
- David Carlisle - Tue, 7 Jan 2003 11:32:36 -0500 (EST)
- Passin, Tom - Tue, 7 Jan 2003 11:20:40 -0500 (EST)
- cknell - Tue, 7 Jan 2003 11:28:56 -0500 (EST)
- Martinez, Brian - Tue, 7 Jan 2003 11:37:12 -0500 (EST) <=
- Patel, Viral - Tue, 7 Jan 2003 12:06:59 -0500 (EST)
- Corey Snow - Tue, 7 Jan 2003 12:25:07 -0500 (EST)
|
|