[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

How to make a simple running example using packages?

Subject: 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
 How to make a simple running example using packages?
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.