[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Use predicates/patterns or xsl:choose (was:] Styl
Hi,
I was reading up all stuff about optimizing the performance of xslt. One basic advice I found is: Michael can probably give the best answer, but I think that it still applies. A parser has to test a node against all available templates and unless wrong ones fail very quickly (or unless some smart optimisation is done), evaluating all match patterns can consume considerable time. Using a choose within a single template for a particular element or node, is more or less like using a hashing mechanism to quickly cut out the templates that are not of interest. This is a rather general thought, so I don't think it is likely to become out of date. I rather split complex templates in more than one and adjust the match patterns accodingly to shorten and simplify the actual code inside the xsl:template. So I try to avoid using xsl:choose or xsl:if areas as much as possible as they make the stylesheet sometimes quite difficult to read and maintain. And I was under the impression that splitting complex templates in easier ones by making the match as precise as possible would also be quicker as I (naively) thought the processor does something like a lookup table before actually performing the transformation. I sometimes split complex templates into multiple ones as well, but usually only in combination with a mode on the template. Having lots of templates in the same scope (mode), isn't usually easier to maintain. I'll leave the question on the lookup table for Michael or someone else.. > So, is it still better to avoid complex patterns or am I understanding the advice in the wrong > way? Ever thought about doing something like: <xsl:template match="my-elem"> <xsl:choose> <xsl:when test="..condition 1.."> <xsl:apply-templates select="." mode="condition1" /> </xsl:when> ... </xsl:choose> </xsl:template> <xsl:template match="my-elem" mode="condition1"> .. handling of my-elem in condition 1 .. </xsl:template> Thanks a lot Chris
|
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
|