Subject: Re: [xsl] Performance differences between xsl:for-each and xsl:template matches From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Wed, 17 Aug 2022 07:10:05 -0000 |
Well, this appears to be working code, and attempting to improve the performance of working code is not "premature" - provided that you have clear evidence that the working code doesn't meet the performance requirements. What it does appear to be, though, is optimization by trial-and-error, which is an equally common fault. But let's ignore the critique of methodology and try to answer the question. There is no reason to believe that using apply-templates and template rules should be faster than for-each. On the contrary, one would expect it to be marginally slower. The reason for advising people to use apply-templates is not for performance improvement, it is to create code that is more robust and maintainable. Michael Kay Saxonica > On 16 Aug 2022, at 22:06, Dimitre Novatchev dnovatchev@xxxxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote: > > To quote Donald Knuth: "Premature optimization is the root of all evil" https://stackify.com/premature-optimization-evil/#:~:text=%E2%80%9CPremature% 20optimization%20is%20the%20root,is%20credited%20to%20Donald%20Knuth <https://stackify.com/premature-optimization-evil/#:~:text=%E2%80%9CPremature %20optimization%20is%20the%20root,is%20credited%20to%20Donald%20Knuth>. > > I think he discovered a general law that is true for all overzealous believers, as one can find ample proofs looking back in history. > > Or, as they say: "The road to hell is paved with good intentions". > > > Thanks, > Dimitre > > > On Tue, Aug 16, 2022 at 10:11 AM Edward Porter edward.porter@xxxxxxx <mailto:edward.porter@xxxxxxx> <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx <mailto:xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>> wrote: > I inherited an older stylesheet that makes extensive use of <xsl:for-each> matching elements (e.g., select=b//chapter[@eid]b) in the root template to then call templates. Using Saxon, would there be any performance improvements if I refactored to use match templates and <xsl:apply-templates> as would generally be the best practice in this case? > > > > -Ed > > > > > > Edward Porter > > Doc Publishing Tech Lead | Documentation Engineering - DevOps > > Tel: + 1 919 531 2349 > > SAS | 100 Campus Drive | Cary, NC 27513 > > > > <image001.gif> > > DID YOU KNOW? > SAS IS THE NO. 1 AI AND ADVANCED ANALYTICS SOFTWARE PLATFORM. <https://www.sas.com/gms/redirect.jsp?detail=GMS114829_158201> > > > > > XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list> > EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/782854> (by email <applewebdata://CCDF5E8B-492E-4527-82AA-313C568A5CF9>) > > > -- > > > XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list> > EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/293509> (by email <>)
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Re: suggestion for an xml edi, Michele R Combs mrro | Thread | Re: [xsl] Performance differences b, Christophe Marchand |
Re: [xsl] Where is 'intersect' Oper, Christophe Marchand | Date | Re: [xsl] Performance differences b, Christophe Marchand |
Month |