Altova Mailing List Archives


Re: [xsl] A question on optimization

From: Geert Josten <Geert.Josten@----------->
To:
Date: 11/3/2004 8:57:00 AM
Hi Jochen,



  <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:for-each
             select="$current/@*[name()=$dbfeld/@dbfeld]">
            <xsl:value-of select="."/>
          </xsl:for-each>
        </xsl:element>
      </xsl:for-each>
    </xsl:element>
  </xsl:for-each>

...



   <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>
       ...
     </xsl:element>
   </xsl:for-each>

David is right. Using // is rather expensive in terms of performance. Use full paths as David 
suggests, or try using keys if the choice and part elements may occur in unpredictable locations:



<xsl:key name="choices" match="justus:choice" use="'all'" />
<xsl:key name="parts" match="justus:part" use="'all'" />

<xsl:for-each select="key('choices', 'all')">



and



<xsl:for-each select="key('parts', 'all')[@visible='true']">



Grtz,
Geert

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.