Altova Mailing List Archives


Re: [xsl] Optimizing XSLT iteration

From: "Sujata Gohad" <sgohad@------->
To:
Date: 10/7/2007 10:15:00 PM
Hi Deborah,

Thanks for your response. I had tried the approach your suggested as
well, but no improvement in performance. :(

I am using Saxon8, that seems to be smartly execute the position()=1
iteration only once. (I verified this using Stylus Studio debugger).


Are there any other suggestions? Any possibility of introducing
parallelism, etc? :-)


Many thanks,
- Sujata

On 10/7/07, Deborah Pickett <debbiep-list-xsl@xxxxxxxxxx> wrote:
> Sujata Gohad wrote:
> >                             <xsl:for-each select="locus[position()=1]">
> >                                 <xsl:text >M </xsl:text >
> >                                 <xsl:value-of select="@ellipse_x"/ >
> >                                 <xsl:text > </xsl:text >
> >                                 <xsl:value-of select="@ellipse_y"/ >
> >                             </xsl:for-each >
> >                             <xsl:for-each select="locus[position()!=1]">
> >                                 <xsl:text > L</xsl:text >
> >                                 <xsl:value-of select="@ellipse_x"/ >
> >                                 <xsl:text > </xsl:text >
> >                                 <xsl:value-of select="@ellipse_y"/ >
> >                             </xsl:for-each >
>
> > Is there a way to faster iteration of the "locus" elements?
>
> See if this is any quicker:
>
> <xsl:for-each select="locus">
>   <xsl:choose>
>     <xsl:when test="position() = 1">
>       <xsl:text>M </xsl:text>
>     </xsl:when>
>     <xsl:otherwise>
>       <xsl:text> L </xsl:text>
>     </xsl:otherwise>
>   </xsl:choose>
>   <xsl:value-of select="@ellipse_x"/ >
>   <xsl:text > </xsl:text >
>   <xsl:value-of select="@ellipse_y"/ >
> </xsl:for-each>
>
> Depending on your XSLT processor, your original code may be constructing
> up to four node-sets: locus, the subset when position() = 1, locus
> (again), the subset when position() != 1.
>
> You're allowed to use position() in almost any expression, not just as
> the predicate of a prior selection.  In my code, position() applies to
> the position that each locus has in the most recent for-each, which is
> what you want.

Disclaimer

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.