Project

Profile

Help

Is there any sample on how to use stylesheetInternal?

Added by Martin Honnen over 3 years ago

The documentation of Saxon-JS 2.3 mentions an object stylesheetInternal supposed to represent a

property contains the stylesheet; the initial structure is the result of JSON parsing of the stylesheet export file, but it will also contain additional properties used to speed up execution. Many of these properties are computed on the first occasion that a particular expression in the stylesheet is evaluated. The tree that is returned on completion of one transformation can be used when initiating subsequent transformations, enabling these to execute with less start-up overhead

i.e. a representation of the stylesheet that can be cached and reused.

However, I am having a hard time to find out how to access that object with some meaningful value in the first place, for me the result object from a transform call always has a property of that name but always with the value undefined.

Test case: https://martin-honnen.github.io/xslt/2021/stylesheetInternalTest1.html

Am I supposed to load the sef.json as a resource to pass that on on the first call? I rather thought that the first call takes the sef.json and then populates result.stylesheetInternal to allow me to cache it and then reuse it on further calls.


Replies (7)

Please register to reply

RE: Is there any sample on how to use stylesheetInternal? - Added by Richard Tweeddale about 3 years ago

The question I've just posted (https://saxonica.plan.io/boards/5/topics/8338) includes a working example of using stylesheetInternal returned from SaxonJS.transform. I've been playing around with it, and I've never seen it have a value of undefined.

RE: Is there any sample on how to use stylesheetInternal? - Added by Martin Honnen about 3 years ago

Thanks for the pointer, I will need to check whether sync versus async use or browser versus server-side Saxon-JS makes the difference between your test and mine.

RE: Is there any sample on how to use stylesheetInternal? - Added by Richard Tweeddale about 3 years ago

Reading the primed stylesheet this way is blisteringly fast compared to compiling it afresh each time :)

RE: Is there any sample on how to use stylesheetInternal? - Added by Michael Kay about 3 years ago

Reading the primed stylesheet this way is blisteringly fast compared to compiling it afresh each time :)

To be honest, we exposed it in the hope and gut feeling that someone might find it useful, without having worked through all the implications in advance.

RE: Is there any sample on how to use stylesheetInternal? - Added by Michael Kay about 3 years ago

I've also been wondering whether a similar approach in SaxonJ might turn out to be a lot more effective than bytecode generation.

RE: Is there any sample on how to use stylesheetInternal? - Added by Martin Honnen about 3 years ago

So the difference seems to be asynchronous versus synchronous processing, at https://martin-honnen.github.io/xslt/2021/stylesheetInternalTest2.html with synchronous processing the returned result has a populated stylesheetInternal property, with asynchronous processing (at https://martin-honnen.github.io/xslt/2021/stylesheetInternalTest1.html) not.

Anyone of the Saxon-JS implementors: is that expected?

RE: Is there any sample on how to use stylesheetInternal? - Added by Debbie Lockett over 2 years ago

Sorry for the delay, but I belatedly added this issue as a bug: Bug #5471: Results object from asynchronous SaxonJS.transform does not contain stylesheetInternal. The fix to include stylesheetInternal in the result from asynchronous transforms will be in the next maintenance release.

    (1-7/7)

    Please register to reply