Project

Profile

Help

Simultaneous XSLT processing

Added by Yevgeniy Yanavichus over 3 years ago

Hello there,

Is there any way to run simultaneous XSLT processing using Saxon PE? Right now each transformation request is waiting until a previous one is finished

Thanks, Yevgeniy


Replies (9)

Please register to reply

RE: Simultaneous XSLT processing - Added by Michael Kay over 3 years ago

Which API are you using, JAXP or s9api? In both cases you can compile a stylesheet once and then execute multiple transformations in different threads simultaneously, using the same compiled stylesheet.

If you show us what you are doing to run transformations at the moment, then it will be easier to explain what you need to change.

RE: Simultaneous XSLT processing - Added by Yevgeniy Yanavichus over 3 years ago

Right now we just run shell command for running transformation using previously precompile stylesheet. Something like:

java -jar PATH_TO_JAR ...

Initially we used SaxonJS.transform with async parameter but then switched to Java in order to call some Java methods from XSLT

Thanks, Yevgeniy

RE: Simultaneous XSLT processing - Added by Michael Kay over 3 years ago

Running Java transformations from the command line is very high overhead because of the Java VM initialization cost. If you're running multiple transformations then you're much better off writing some Java code and using the transformation API. Alternatively, if you don't want to write Java code, consider running from Ant or from XProc (e.g. Calabash).

RE: Simultaneous XSLT processing - Added by Yevgeniy Yanavichus over 3 years ago

Thanks for clarifications, will try those approaches.

One more quick question: is it possible to use Java functions inside XSLT when running transformation using SaxonJS?

RE: Simultaneous XSLT processing - Added by Michael Kay over 3 years ago

No, Saxon-JS supports calling out to Javascriipt, but not to Java.

RE: Simultaneous XSLT processing - Added by Yevgeniy Yanavichus over 3 years ago

What's a recommended way to generate unique UUID's inside compiled Saxon-JS SEF files running on NodeJS then? We should call JavaScript functions inside XSLT?

RE: Simultaneous XSLT processing - Added by Michael Kay over 3 years ago

For some purposes, generate-id() meets the requirement. Or random-number-generator(). But for a genuine UUID, you need to call out to Javascript.

RE: Simultaneous XSLT processing - Added by Yevgeniy Yanavichus over 3 years ago

We used generate-id in our XSLT function which returns unique UUIDs. It works flawlessly on dev machine but in production we started getting duplicates.

We're testing different approaches now and got some more questions:

  1. If we run transformation using transform command from Saxon/C distribution, is it possible to have a unique UUIDs somehow in the final XML? I mean maybe we can call some extension function in this case

  2. If no, can we somehow use a C++ API with the same result (i.e. having unique UUIDs)?

RE: Simultaneous XSLT processing - Added by Michael Kay over 3 years ago

We could explore why generate-id() isn't working for you -- it may be an optimization issue, and there may be a workaround, but we would need to see your code and reproduce the problem.

Calling out to an extension function is in some ways a cleaner solution, though even then, any attempt to write impure functions can lead to optimization problems.

    (1-9/9)

    Please register to reply