RE: [xsl] [XSLT] [Q] Recursion Question/Concern

Subject: RE: [xsl] [XSLT] [Q] Recursion Question/Concern
From: "Chris Bayes" <Chris@xxxxxxxxxxx>
Date: Wed, 21 Mar 2001 19:01:06 -0000
Jonathan,
Can't you just do this
<xsl:template match="INFO1">
<xsl:value-of select="count(preceding::INFO1)+1" /><xsl:text>
</xsl:text><xsl:value-of select="." />
</xsl:template>

Ciao Chris

XML/XSL Portal
http://www.bayes.co.uk/xml


>-----Original Message-----
>From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
>[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Jonathan
>Calvert
>Sent: 21 March 2001 18:27
>To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
>Subject: [xsl] [XSLT] [Q] Recursion Question/Concern
>
>
>I am new to the list, so please forgive me if I am
>asking something answered elsewhere.  I have searched
>the archive and FAQ and have not found the answer I am
>seeking.
>
>I need to count and number "records" in an XML file.
>It would seem that recursion is the answer, but I am
>concerned about performance.
>
>When using recursion I have noticed a 10:1 performance
>decrease over not using recursion.  I assume that user
>error is responsible.
>
>If I do not use a recursive function then my template
>will process in roughly 1 second.  I do not get the
>desired results because I need individual numbered
>lines.  When I use the recursive function then
>performance goes to roughly 10 seconds.
>
>Any and all help would be appreciated.  Thanks in
>advance for your time.
>
>
>Example of XML file format:
>
><DATA>
>  <RECORD>
>    <INFO1>xyz</INFO1>
>  </RECORD>
>  <RECORD>
>    <INFO1>abc</INFO1>
>  </RECORD>
>...
></DATA>
>
>The desired result would be:
>1 xyz
>2 abc
>...
>
>
>In my XSL document I do the following:
><xsl:template match="/">
>  <xsl:call-template name="NumberStuff">
>     <xsl:with-param name="Counter" select="1"/>
>  </xsl:call-template>
></xsl:template>
>
>
><xsl:template name="NumberStuff">
>  <xsl:param name="Counter" />
>
>  <xsl:if test="count(//RECORD) + 1 > $Counter">
>
>    <xsl:value-of select="$Counter"/>
>    <xsl:text>|</xsl:text>
>    <xsl:value-of select"//INFO1">
>
>    <xsl:call-template name="NumberStuff">
>      <xsl:with-param name="Counter" select="$Counter
>+ 1" />
>    </xsl:call-template>
>
>  </xsl:if>
></xsl:template>
>
>__________________________________________________
>Do You Yahoo!?
>Get email at your own domain with Yahoo! Mail.
>http://personal.mail.yahoo.com/
>
> XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>


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


Current Thread