If you are running from the command line, it is possible to load multiple
packages by providing a semicolon-separated list of filenames in the -xsl
parameter. However, I don't think this is well documented or tested and it may
have restrictions concerning the order of packages.
What is documented and tested is using packages via the s9api XsltCompiler
interface; essentially you can compile a package into a CompiledPackage
object, and then make this available to an XsltCompiler using an importPackage
method.
This is a bit of a stopgap; packages are work in progress. We're thinking
about "classpath-like" mechanisms for the longer term.
Michael Kay
Saxonica
mike@xxxxxxxxxxxx
+44 (0) 118 946 5893
On 19 Oct 2014, at 00:46, Dimitre Novatchev <dnovatchev@xxxxxxxxx> wrote:
> Hi,
>
> Using the trial version of Saxon 9.6EE and the example package from
> the latest XSLT 3.0 Last Call, I am trying to produce a simple,
> running example:
>
> using-package.xsl:
> ==============
> <xsl:package name="http://example.org/complex-arithmetic.xsl"
> package-version="1.0" version="3.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns:f="http://example.org/complex-arithmetic.xsl">
> <xsl:use-package name="complex-arithmetic"/>
>
> <xsl:template match="/">
> <xsl:variable name="vComplex1" select="f:complex-number(1, 0)"
> as="map(xs:integer, xs:double)"/>
> Real: <xsl:sequence select="$vComplex1(0)"/>
> Imaginary: <xsl:sequence select="$vComplex1(1)"/>
> </xsl:template>
> </xsl:package>
>
>
>
> complex-arithmetic.xsl:
> =================
> <xsl:package name="complex-arithmetic"
> package-version="1.0" version="3.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns:f="http://example.org/complex-arithmetic.xsl">
>
> <xsl:function name="f:complex-number"
> as="map(xs:integer, xs:double)" visibility="public">
> <xsl:param name="real" as="xs:double"/>
> <xsl:param name="imaginary" as="xs:double"/>
> <xsl:sequence select="map{ 0:$real, 1:$imaginary }"/>
> </xsl:function>
>
> <xsl:function name="f:real"
> as="xs:double" visibility="public">
> <xsl:param name="complex" as="map(xs:integer, xs:double)"/>
> <xsl:sequence select="$complex(0)"/>
> </xsl:function>
>
> <xsl:function name="f:imag"
> as="xs:double" visibility="public">
> <xsl:param name="complex" as="map(xs:integer, xs:double)"/>
> <xsl:sequence select="$complex(1)"/>
> </xsl:function>
>
> <xsl:function name="f:add"
> as="map(xs:integer, xs:double)" visibility="public">
> <xsl:param name="x" as="map(xs:integer, xs:double)"/>
> <xsl:param name="y" as="map(xs:integer, xs:double)"/>
> <xsl:sequence select="
> f:complex-number(
> f:real($x) + f:real($y),
> f:imag($x) + f:imag($y)"/>
> </xsl:function>
>
> <xsl:function name="f:multiply"
> as="map(xs:integer, xs:double)" visibility="public">
> <xsl:param name="x" as="map(xs:integer, xs:double)"/>
> <xsl:param name="y" as="map(xs:integer, xs:double)"/>
> <xsl:sequence select="
> f:complex-number(
> f:real($x)*f:real($y) - f:imag($x)*f:imag($y),
> f:real($x)*f:imag($y) + f:imag($x)*f:real($y))"/>
> </xsl:function>
>
> <!-- etc. -->
> </xsl:package>
>
> When I run Saxon 9.6 on using-package.xsl, I get these error messages:
>
> Saxon-EE 9.6.0.1J from Saxonica
> Java version 1.7.0_51
> Using license serial number Vxxxxxxxxxxxxxxx
>
> Error at xsl:use-package on line 6 column 47 of marrowtr.xsl:
> XTSE3000: Package complex-arithmetic was not found
>
> Error at xsl:variable on line 9 column 101 of marrowtr.xsl:
> XPST0017 XPath syntax error at char 0 on line 9 in {f:complex-number(1,
0)}:
> Cannot find a matching 2-argument function named
> {http://example.org/complex-arithmetic.xsl}complex-number()
>
> Stylesheet compilation failed: 2 errors reported
>
>
> What should I do in order to make this simple example run as expected?
>
> It is not clear to me how finding a package given its name works -- I
> also tried importing complex-arithmetic.xsl into using-package.xsl,
> but got this error:
>
> "Error at xsl:import on line 8 column 46 of marrowtr.xsl:
> XTSE0165: Included document complex-arithmetic.xsl is not a stylesheet"
>
>
> Any guidance how to produce a running example is enormously appreciated.
>
>
> --
> Cheers,
> Dimitre Novatchev
>
>
-----------------------------------------------------------------------------
-
> Comprehensive Server Monitoring with Site24x7.
> Monitor 10 servers for $9/Month.
> Get alerted through email, SMS, voice calls or mobile push notifications.
> Take corrective actions from your mobile device.
> http://p.sf.net/sfu/Zoho
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> saxon-help@xxxxxxxxxxxxxxxxxxxxx
> https://lists.sourceforge.net/lists/listinfo/saxon-help
|