Re: XSLT 3.0 packages in Saxon 9 and 10

Michael Kay <mike-JkSD5nQpfvpWk0Htik3J/[email protected]> Tue, 12 Jan 2021 09:32:58 +0000
Newsgroups gmane.text.xml.saxon.help
Message-ID <[email protected]>
To be honest, I think we're still learning about the strategies you can use for this, and their advantages and disadvantages. Managing software package dependencies is never straightforward, and a lot depends on the details, e.g. how much you trust new versions of packages to be compatible.

We've also found a few gaps in the language spec, for example the fact that xsl:use-package provides no way of setting the static parameters in the used package.

I think there are two basic approaches available: using configuration files, or using the s9api API.

My feeling is that configuration files are the simplest way to do it, but they may not offer all the flexibility you need:

https://saxonica.com/documentation/index.html#!configuration/configuration-file

The PackageLibrary class isn't part of s9api, which iindicates that it's more of an internal mechanism than something we would expect users to need to use directly (unless they're building some kind of higher-level packaging mechanism as a layer on top). I think your confusion with this class is that it's not very clearly documented; it can hold details of both compiled and not-yet-compiled packages, and the state transitions aren't very clearly described.

I think the expectation is that if you're controlling this from the Java API (rather than using a configuration file), then you should be using the various methods on XsltCompiler.

Another thing that might not always be clear is that when you export a stylesheet as a SEF file, the resulting SEF file contains all the dependent packages. So the simplest way to deploy a set of packages making up an application is to compile the whole thing into a monolithic SEF file.

Whether you use a configuration file or the XsltCompiler API, the "location" URIs for locating modules should allow JAR file URIs and classpath URIs, so putting the files in a JAR shouldn't be a problem.

Michael Kay
Saxonica



> On 11 Jan 2021, at 17:45, Jeremy Cronk <[email protected]> wrote:
> 
> Hi, 
>  
> I’ve spent a lot of time experimenting and reading the API docs and I’m confused, so I’ll just ask: What’s the “preferred” way in Saxon to load a set of XSLT package files (say, from a jar file) for use in transformations?  I see you can compile and add packages with XsltCompiler, but it looks like it would make more sense to use a PackageLibrary.  However, I haven’t successfully been able to add packages to one, so I’m sure I’m missing something really obvious.  If I call addPackage and pass in an .xsl file as a File, it doesn’t complain, but if I call getPackages on the same PackageLibrary, it returns an empty list.  It looks like the same thing happens with .sef files.    
>  
> Is there something like “XSLT 3.0 Packages for Absolute Morons” out there somewhere that I could read and follow?  I’m having trouble understanding the intent of the different ways to load packages, not to mention the issue of getting it to work.  What I’d love to be able to do is store the SEF files in a jar and load everything in the jar as a package, and it looks like in order to do that, I need to compile them with “relocatable” turned on, stick them in a jar, and then…something with PackageLibrary?
>  
> Also, is it correct to say that a package compiled on Saxon 9 won’t work on Saxon 10?  When I tried this, I got a NPE, but after compiling the stylesheet with Saxon 10, it worked fine (on 10; I didn’t try it again on 9).  
>  
> Jeremy
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/ <http://saxon.markmail.org/>
> [email protected] <mailto:[email protected]>
> https://lists.sourceforge.net/lists/listinfo/saxon-help <https://lists.sourceforge.net/lists/listinfo/saxon-help>

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