Saxon can't find package

607 views Asked by At

I encounter some difficulties when using packages with Saxon 9.8. Saxon can't find the package I want to use and fail at compilation.

When using the -lib option from the command line, I get the following error message:

java.lang.NullPointerException
        at net.sf.saxon.style.PackageVersion.<init>(PackageVersion.java:71)
        at net.sf.saxon.trans.packages.VersionedPackageName.<init>(VersionedPackageName.java:29)
        at net.sf.saxon.trans.packages.PackageInspector.getNameAndVersion(PackageInspector.java:78)
        at et.sf.saxon.trans.packages.PackageInspector.getPackageDetails(PackageInspector.java:91)
        at net.sf.saxon.trans.packages.PackageLibrary.<init>(PackageLibrary.java:96)
        at net.sf.saxon.Transform.doTransform(Transform.java:404)
        at net.sf.saxon.Transform.main(Transform.java:81) Fatal error during transformation: java.lang.NullPointerException:  (no message)

When using -lib option in oXygen 19 with the Saxon 9.8 add-on, I get the following message:

Nom du moteur: Saxon-EE 9.8.0.4 (External)
Gravité: fatal
Description: Cannot find package img_pkg (version *)
Emplacement de début: 7:52

I get exactly the same error message in oXygen when I use a configuration file to declare the package.

I'm pretty sure that there is no problem with the file path. Since in the error message I get in oXygen the package version doesn't seem to be recognized, I thought it could be a syntax problem but I can't find where it comes from.

Here is test my package:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:package name="img_pkg" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:img="https://www.ephe.fr/annuaire/colin-brisson"
    exclude-result-prefixes="xs img" version="1.0">

    <xsl:function name="img:test" visibility="final" as="xs:string">
       <xsl:value-of select="'test ok'"/>
    </xsl:function>

</xsl:package>

Here's my test sylesheet:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:img="https://www.ephe.fr/annuaire/colin-brisson" exclude-result-prefixes="xs"
    version="3.0">

    <xsl:use-package version="1.0" name="img_pkg"/>

    <xsl:template name="xsl:initial-template">

        <xsl:message>
            <xsl:value-of select="img:test()"/>
        </xsl:message>

    </xsl:template>

</xsl:stylesheet>

Many thanks in advance!

1

There are 1 answers

0
Michael Kay On BEST ANSWER

I think that the NullPointerException from the command line is due to bug 3373

https://saxonica.plan.io/issues/3373

although in your case the root cause is a little different from that in the bug entry, it's the absence of a package-version attribute. This is fixed in 9.8.0.4, but from the line numbers in the stack trace it looks to me as if you are using an earlier maintenance release.

The problem in oXygen is probably completely different, but it might again be related to the absence of @package-version.