Re: [xsl] A question on optimization

Subject: Re: [xsl] A question on optimization
From: Jochen Wiedmann <jochen.wiedmann@xxxxxxxxxx>
Date: Tue, 02 Nov 2004 15:40:54 +0100

first of all, thanks for your reply.

David Carlisle wrote:

an xslt stylesheet is an xml document so you can transform it using
various methods, not least another xslt stylesheet. The details depend
on which API you are using.

You are, of course, right. Unfortunately, the stylesheet is applied in an environment, where I am limited to static files. (I can use includes,
but that's all.)

It's unlikely to make any real difference on performace though.
Time is far more likely to be spent on navigating the tree as a whole
rather than on the fine details of the instructions used to generate a
small local result fragment.

You are most probably right. I'd possibly better quote my actual loop:

  <xsl:for-each select="//justus:choice">
    <xsl:element name="TR">
      <xsl:variable name="current" select="."/>
      <xsl:for-each select="//justus:part[@visible='true']">
        <xsl:variable name="dbfeld" select="."/>
        <xsl:element name="td">
            <xsl:value-of select="."/>

The document consists of two sequences. The first sequence has justus:part nodes, with two attributes: visible (true|false), the second sequence contains justus:choice nodes, with the actual data. The column names are read from justus:part/@dbfeld.

For a given input instance, I can replace the above with

   <xsl:for-each select="//justus:choice">
     <xsl:element name="tr">
       <xsl:element name="td"><xsl:value-of select="a1"/></xsl:element>
       <xsl:element name="td"><xsl:value-of select="a2"/></xsl:element>

The former needs 57 seconds, the latter only 5 seconds. Thus my interest is indeed to reduce the required navigation within the justus:part nodes. Any ideas?




Current Thread