Multi-threading considerations

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Multi-threading considerations

cmarchand

 

 

Hello all,

 

I have to transform the same source document with the same XSL many times, each time with a different parameter-value.

I know I can share the same XsltExecutable between different threads (via XsltExecutable.load()), but can I share the same source document between different threads ?

 

Best regards,

Christophe

 


------------------------------------------------------------------------------

_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Multi-threading considerations

Michael Kay
Yes, you can do this. Build the document using 

processor.newDocumentBuilder().buildDocument() -> XdmNode

and then pass it to the XsltTransformer using setContextItem().

The XdmNode is thread-safe and immutable unless you use XQuery Updates.

We did find a bug in this area if you use accumulators, and there was an earlier bug using xsl:key if the match or use attributes are dependent on the values of stylesheet parameters: so make sure you use the current 9.6 release.

Michael Kay
Saxonica


On 7 Sep 2015, at 12:39, [hidden email] wrote:

 
 

Hello all,

 

I have to transform the same source document with the same XSL many times, each time with a different parameter-value.

I know I can share the same XsltExecutable between different threads (via XsltExecutable.load()), but can I share the same source document between different threads ?

 

Best regards,

Christophe

 
------------------------------------------------------------------------------
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help


------------------------------------------------------------------------------

_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Multi-threading considerations

cmarchand
Thanks a lot !
I don't think we are in the cases you describe, but I'm gonna check this.

Best regards,
Christophe

Le 07/09/2015 18:08, Michael Kay a écrit :
Yes, you can do this. Build the document using 

processor.newDocumentBuilder().buildDocument() -> XdmNode

and then pass it to the XsltTransformer using setContextItem().

The XdmNode is thread-safe and immutable unless you use XQuery Updates.

We did find a bug in this area if you use accumulators, and there was an earlier bug using xsl:key if the match or use attributes are dependent on the values of stylesheet parameters: so make sure you use the current 9.6 release.

Michael Kay
Saxonica


On 7 Sep 2015, at 12:39, [hidden email] wrote:

 
 

Hello all,

 

I have to transform the same source document with the same XSL many times, each time with a different parameter-value.

I know I can share the same XsltExecutable between different threads (via XsltExecutable.load()), but can I share the same source document between different threads ?

 

Best regards,

Christophe

 
------------------------------------------------------------------------------
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help



------------------------------------------------------------------------------


_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 


------------------------------------------------------------------------------

_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help