Random photo
Loading...
Domains for sale
|
April 24, 2006How to check if XslCompiledTransform instance has already loaded a stylesheetXslCompiledTransform provides amazing transformation performance, but obviously not without a price. As with any compiling system the price is slower and quite resource consuming compilation stage. That's why it's very important to cache loaded XslCompiledTransform instance to avoid paying compilation price over again. One question that comes sometimes while implementing caching/pooling systems for XslCompiledTransform is how to check if XslCompiledTransform instance has been already loaded with a stylesheet? XslCompiledTransform design separates object construction and initialization for the sake of reusability (to be able to load another XSLT stylesheet into the same XslCompiledTransform instance). I believe that's a legacy issue as it contradicts with always-cache-loaded-XslCompiledTransform mantra. And unfortunately currently XslCompiledTransform provides no property to check if the stylesheet was already loaded and XslCompiledTransform instance is ready to be used. Hopefully in the next version we will get such one. But currently here is a trick that can be used - check OutputSettings property for not null. It's always null when Load() method has not been called and always not null after that. This is pretty much safe and I was assured by guys at the Microsoft XML team responsible for the XslCompiledTransform that this behaviour won't be changed. April 24, 2006 11:15 AM
| #XSLT
Comments
HOw to implement caching system for XslCompiledTransform? Posted by: swati at September 12, 2006 4:32 AMWell, you are right, this really sounds like a weird problem. Should admit I was too busy to understand what exactly the problem is... The original question was like this: "Is there a way to determine if an instance of the XslCompiledTransform class Oleg, I'm puzzled. Why would one want to reuse an XslCompiledTransform instance while loading it with a new stylesheet ? The cost of "new XslTransform" (the constructor is empty !) is so ridiculous compared to the price of compilation that it's not even funny. Post a comment
|