fastest in-memory cache for XslCompiledTransform

可紊 提交于 2019-12-08 01:46:50

问题


I have a set of xslt stylesheet files. I need to produce the fastest performance of XslConpiledTransform, so i want to make in-memory representation of these stylesheets.

I can load them to in-memory collection as IXpathNavigable on application start, and then load each IXPAthNavigable into singleton XslCompiledTransform on each request. But this works only for styleshhets without xsl:import or xsl:include. (Xsl:import is only for files).

also i can load into cache many instances of XSLCompiledTransform for each template. Is it reasonable?

Are there other ways? What is the best? what are another tips for improving performance MS Xslt processor?


回答1:


After the successful execution of Load() on an instance of XslCompiledTransform, this instance can be cached in order to achieve better performance.

Do remember that Load() is a very expensive operation.




回答2:


Instead of compiling and caching XSL transforms at run time you can use the MS SDK tool xsltc.exe (XSL compiler) to generate assemblies.

At runtime your application will then either load these assemblies dynamically (or you can just add static references to your application) and call the overloaded XslCompiledTransform.Load( System.Type type) method to load the type that you compiled into the XSL assembly.

This is the absolute fastest way since you dont incur the compile penalty of runtime - only at build/compile time.



来源:https://stackoverflow.com/questions/615991/fastest-in-memory-cache-for-xslcompiledtransform

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!