How do I include a compiled stylesheet (sep) in a separate stylesheet (xsl)?
Added by Craig Cothren over 7 years ago
I'm compiling stylesheets (XSL) for use with the SaxonJS into their compiled form (SEP).
$ java -jar saxon9ee.jar -target:JS -xsl:child.xsl -export:child.sef.xml -nogo
I would like to use the compiled child stylesheet in another parent stylesheet via an include.
But when I compile the parent stylesheet, I get errors.
$ java -jar saxon9ee.jar -target:JS -xsl:parent.xsl -export:parent.sef.xml -nogo
Static error at package on line 2 column 352 of child.sef.xml:
XTSE0150: The supplied file does not appear to be a stylesheet
Errors were reported during stylesheet compilation
I know if I include the uncompiled child.xsl that it will work, but I do not want to have to deliver the child.xsl to the team composing the parent.xsl, only the compiled version, child.sep.xml.
Is there a technique where they can include the compiled version?
Replies (3)
Please register to reply
RE: How do I include a compiled stylesheet (sep) in a separate stylesheet (xsl)? [cross posted from SaxonCE] - Added by Michael Kay over 7 years ago
Stylesheet packages can be compiled separately; stylesheet modules can't. This is why XSLT 3.0 packages were introduced, with controls on which components in a library package are visible to the using package. So you need to use xsl:use-package rather than xsl:include.
(The XSLT 1.0/2.0 xsl:include and xsl:import mechanisms didn't impose enough constraints to allow separate compilation. For example a function or template returning an integer could be replaced in a different module by one returning a string. That makes it almost impossible for the compiler to make any execution plans. Packages solve this by defining constraints: you can only override a component with another having the same interface.)
At the moment, the linking of separately-compiled packages has to be done server-side; it can't be done by Saxon-JS within the browser. So you can develop a library package L, compile it into a SEF file, incorporate this in a top-level package M via use-package, and then export M as a SEF file, which will include everything needed from L, and then load M.sef from the application in the browser.
RE: How do I include a compiled stylesheet (sep) in a separate stylesheet (xsl)? - Added by Craig Cothren over 7 years ago
Thank you Dr. Kay. I will attempt to implement my construct using packages. I have not had an opportunity to learn this feature and wondered if you could suggest a good online tutorial.
RE: How do I include a compiled stylesheet (sep) in a separate stylesheet (xsl)? - Added by Michael Kay over 7 years ago
I regret that you're somewhat on the bleeding edge here. XSLT 3.0 packages are very new and there's not much community experience to learn from. Perhaps you need to be the one that writes the tutorial.
Please register to reply