xslt-3.0

alternatives to import/include for importing library functions


I sometimes use xsl:import/xsl:include to import library functions, but its a bit clumsy. Things like saxon seem to import libraries by magic based on including a namespace in the root.

I probably have about 10 or so smallish (< 500 lines) files of XSLT code that I use, I'm just wondering if I'm doing this the sensible way?

I've tried xsl:include mostly to date.

I think I'd like to be able to take several xslt files that I current include and 'compile' them somehow into a single file/module/binary, that i can then refer to from the client code, and saxon to know where to get it from and what to do.


Solution

  • This is going to be processor-dependent, but since the various flavours of Saxon are about the only XSLT-3.0 game in town, I'll talk about SaxonJ.

    The functions available to you basically come from three sources:

    There's no mechanism to add functions written in XSLT via any Java API or configuration file, they can only be made available using the language features of xsl:include, xsl:import, and xsl:use-package.