Subject: [xsl] How to make a simple running example using packages? From: "Dimitre Novatchev dnovatchev@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Sat, 18 Oct 2014 23:46:55 -0000 |
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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Many Key values question, Jean-Pierre Lamon gi | Thread | [xsl] Re: [saxon] How to make a sim, Michael Kay mike@xxx |
Re: [xsl] Many Key values question, Jean-Pierre Lamon gi | Date | [xsl] Re: [saxon] How to make a sim, Michael Kay mike@xxx |
Month |