Project

Profile

Help

saxon:import-query inside PE-Saxon xslt

Added by Jiri Dolejsi over 7 years ago

Is it possible to use saxon:import-query extension element from Saxon-PE? It seems to need to precompile xquery module, which is not available in Saxon-PE. We are using Saxon 9.8 in .NET.


Replies (7)

Please register to reply

RE: saxon:import-query inside PE-Saxon xslt - Added by Michael Kay over 7 years ago

I can't immediately see why it shouldn't be possible, though I don't have the right environment to test it just now.

Have you considered using the new XSLT 3.0 / XPath 3.1 fn:load-query-module() function instead? Using standard language features rather than Saxon extensions has several advantages:

  • they are portable across implementations
  • they are specified much more carefully, with more attention to edge cases, and with more examples
  • they are more thoroughly tested
  • they are more likely to remain compatible in future Saxon releases.

RE: saxon:import-query inside PE-Saxon xslt - Added by Jiri Dolejsi over 7 years ago

My first impression was, that in the case of saxon:import-query xquery module is compiled and held compiled in configuration, while in the case of fn:load-query-module() xquery module is loaded and compiled everytime when called. But if not true, I will try this function.

RE: saxon:import-query inside PE-Saxon xslt - Added by Michael Kay over 7 years ago

load-query-module does indeed parse the query when you call it, but it returns a data structure containing a set of function objects which can then be called repeatedly. So if you know statically (or by way of a stylesheet parameter) what query module you want to load, you can put the call on load-query-module in a global variable and it will only be called once.

You could probably even bind the result of load-query-module to a static variable, in which case it would be called at XSLT compile time, though I haven't tried that.

RE: saxon:import-query inside PE-Saxon xslt - Added by Jiri Dolejsi over 7 years ago

We are using xslt stylesheets inside application server written in C#. When xslt is first used, it is compiled and then cached. My concern was, not to compile xquery module in each run. So I think only your last suggestion about static variable solves this ?

RE: saxon:import-query inside PE-Saxon xslt - Added by Michael Kay over 7 years ago

I have now verified that you can bind a stylesheet statically to a query module:

   
   
   
   
   
              
         
      
   

XSLT 3.0 test case load-xquery-module-004

RE: saxon:import-query inside PE-Saxon xslt - Added by Michael Kay about 7 years ago

I've discovered that we actually have rather few tests for saxon:import-query - some of them appear to have gone missing when we reorganised test material a while ago. If you have cases that aren't working, please report them.

    (1-7/7)

    Please register to reply