Reputation: 23
Using Saxon 9 HE, it takes a few seconds to compile style sheet (in .Net).
Can any one verify that compiled transform is thread safe. i.e. If i compile style sheet and hold onto the instance to invoke in future. Will invoking this compiled Transform instance simultaneously from multiple thread cause any issue?
XsltTransformer transformer = proc.NewXsltCompiler().Compile(new Uri("file:///" + styleSheet)).Load();
//Store transformer instance as class variable and reuse it to eliminate compilation time
Upvotes: 2
Views: 774
Reputation: 167696
See the documentation on saxonica.com, you only need to compile once XsltExecutable ex = proc.NewXsltCompiler().Compile(new Uri("file:///" + styleSheet));
and can then use the XsltExecutable
in several threads: "An XsltExecutable is immutable, and therefore thread-safe.".
About XsltTransformer
, it says "An XsltTransformer should not be used concurrently in multiple threads. It is safe, however, to reuse the object within a single thread to run the same stylesheet several times.".
Upvotes: 2