Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

Performance enhancement 1

2007-07-03
2012-10-08
  • Serge Emmanuel
    Serge Emmanuel
    2007-07-03

    Hello all xsl gurus,

    I have many style sheets files, that are either used multiple times or take a long to execute. however we use <xsl:include ..> to include these style sheets and my question: is <xsl:include ..> a performance killer? if yes how or which xsl elements can I use to replace <xsl:include ..>, so that the same functionality can be supported and what about the element <xsl:key>?

    thanks for advance.

     
    • Michael Kay
      Michael Kay
      2007-07-04

      xsl:include isn't intrinsically expensive, in the sense that a stylesheet containing 500 template rules will perform the same both at compile time and at run-time whether those rules are all in one module or spread across 50. However, it's also true that xsl:include gives no performance benefit, in particular if a stylesheet module is used from lots of places then it gets separately compiled for each one. But if you've got performance problems, you probably need to look elsewhere. Try the tool described at http://www.saxonica.com/documentation/using-xsl/performanceanalysis.html to see where the time is going.

       
    • Serge Emmanuel
      Serge Emmanuel
      2007-07-05

      Thanks Micheal for your rapid answer. I am trying to solve these performance problems und one solution should be a stylesheet module, that is used from lots of places to compile once and then to cache the result and thereby each module, that uses this stylesheet module will get them from the cache.
      But I do not see some examples, that can help me to test this issue. maybe there is already BEST PRACTICES about. If you know some best practices,then that would great if you send me.

       
      • Michael Kay
        Michael Kay
        2007-07-05

        Sorry if my reply wasn't clear. I'll try again:

        (a) you can only compile a stylesheet module as part of a complete stylesheet. If a module is part of several stylesheet then it has to be compiled separately in each one.

        (b) I think it's unlikely that this is the explanation of your performance problems. What investigation have you done to make you think this?

        Michael Kay
        Saxonica

         
        • dreamair
          dreamair
          2007-09-07

          Hi Michael,

          I think, I get the xsl:include problem, but is maybe an xsl:import able to reuse prepared stylesheets? Since imported ones are complete stylesheets them selfs and not only part of a compilation.

          or generally, would the processor be able to cache imported stylesheets?

          An example setup could include a stylesheet A.xsl importing B.xsl and C.xsl. Both B.xsl and C.xsl import a base.xsl. The processor resolves base.xsl twice. When browsing the source code I find no reuse of stylesheet modules (PreparedStylesheet.loadStylesheetModule()). Why is this not possible? Couldn't we at least cache the memory DOM (includedDoc), so we don't need to parse the Source for base.xsl twice?

          Thanks,

          Bruno Feurer
          FeurerWorks