|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Number of times apply-templates gets executed.
> 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








