Bug #4975

Null pointer exception when XSLT 3.0 run from the command line

Added by Graydon Saunders 25 days ago. Updated 5 days ago.

Start date:
Due date:
% Done:


Estimated time:
Legacy ID:
Applies to branch:
10, trunk
Fix Committed on Branch:
10, trunk
Fixed in Maintenance Release:


in oXygen ( XML Editor 23.1, build 2021040908) with the 10.3 external add-on, the transform (small.xsl) works. oXygen 23 uses a Java 15 JRE

17:40 bin % ./java --version openjdk 15.0.1 2020-10-20 OpenJDK Runtime Environment (build 15.0.1+9-18) OpenJDK 64-Bit Server VM (build 15.0.1+9-18, mixed mode)

If I try to call small.xsl from the shell (Linux; Fedora 33, bash 5.0.17) using, I get a null pointer error.

I believe I have exhausted my ingenuity on this one and have a minimal example which I would prefer to send under separate cover.

The code from which the minimal example has been extracted has been working fine in oXygen; the minimal example itself runs fine in oXygen. Trying to run it from the command line for automated testing purposes hasn't made it past the null pointer error. Various other transforms run fine, Saxon finds the license OK, etc. I get what I think is the same error with Saxon 10.3 and 10.5, and with Java 11 and Java 16.

15:48 tests % java --version openjdk 11.0.10 2021-01-19 OpenJDK Runtime Environment 18.9 (build 11.0.10+9) OpenJDK 64-Bit Server VM 18.9 (build 11.0.10+9, mixed mode, sharing)

15:54 tests % /etc/alternatives/java_sdk_16/bin/java --version openjdk 16 2021-03-16 OpenJDK Runtime Environment 21.3 (build 16+36) OpenJDK 64-Bit Server VM 21.3 (build 16+36, mixed mode, sharing)

Stack Trace: 17:42 tests % ./ (DITA2Word)-[one-githubTests-gds] java.lang.NullPointerException at java.base/java.util.Objects.requireNonNull( at net.sf.saxon.trans.XmlProcessingIncident.( at net.sf.saxon.Controller.warning( at net.sf.saxon.resource.XmlResource.getItem( at net.sf.saxon.resource.UnknownResource.getItem( at net.sf.saxon.resource.MetadataResource.lambda$getItem$0( at at net.sf.saxon.functions.SystemFunction.dynamicCall( at at net.sf.saxon.expr.FunctionCall.iterate( at net.sf.saxon.expr.CardinalityChecker.evaluateItem( at net.sf.saxon.expr.ItemChecker.evaluateItem( at net.sf.saxon.expr.parser.Evaluator$5.evaluate( at net.sf.saxon.expr.parser.Evaluator$5.evaluate( at net.sf.saxon.expr.UserFunctionCall.evaluateArguments( at net.sf.saxon.expr.UserFunctionCall.evaluateArguments( at net.sf.saxon.expr.UserFunctionCall.callFunction( at net.sf.saxon.expr.UserFunctionCall.evaluateItem( at net.sf.saxon.expr.LookupExpression.iterate( at net.sf.saxon.expr.parser.Evaluator$7.evaluate( at net.sf.saxon.expr.SystemFunctionCall.evaluateArguments( at net.sf.saxon.expr.FunctionCall.iterate( at at at at at net.sf.saxon.expr.instruct.ForEach.processLeavingTail( at net.sf.saxon.expr.instruct.Instruction.process( at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail( at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail( at at net.sf.saxon.expr.instruct.NamedTemplate.expand( at net.sf.saxon.trans.XsltController.callTemplate( at net.sf.saxon.s9api.Xslt30Transformer.callTemplate( at net.sf.saxon.Transform.processFile( at net.sf.saxon.Transform.doTransform( at net.sf.saxon.Transform.main( Fatal error during transformation: java.lang.NullPointerException: (no message)


#1 Updated by Michael Kay 25 days ago

It's a little bit puzzling because there is no call to Controller.warning() at UnknownResource.getItem()(, however, I can see several calls to Controller.warning() (in CatalogCollection, DirectoryCollection, and XmlResource) that will trigger this crash because they set the location parameter to null.

All three of these warnings are triggered when you specify on-error=warning in the query parameters of a collection URI, so as a workaround, try locating this and changing it to on-error=ignore or on-error=fail.

The fact that there's an UnknownResource means that Saxon wasn't able to decide what kind of resource it would get (e.g. XML, JSON, binary, etc) from the filename/URI alone, probably because there was no file extension. You might also find you can avoid the problem by using something like select=*.xml in the collection URI to select only those resources with a known file extension.

#2 Updated by Michael Kay 25 days ago

Thanks for sending the repro (offline). Sure enough, line 85 uses on-error=warning, so changing that should enable you to make progress while we fix the bug.

#3 Updated by Graydon Saunders 25 days ago

Thanks for sending the repro (offline). Sure enough, line 85 uses on-error=warning, so changing that should enable you to make progress while we fix the bug.

on-error=ignore continues to produce a null-pointer exception;
on-error=fail fails politely on a specific file, which I can certainly

Thank you; gets me unstuck.

On Thu, Apr 22, 2021 at 07:20:45PM +0200, Saxonica Developer Community scripsit:

#4 Updated by Michael Kay 5 days ago

  • Category set to Diagnostics
  • Status changed from New to Resolved
  • Applies to branch trunk added
  • Fix Committed on Branch 10, trunk added

I have changed Controller.warning() so that it tolerates any of the three arguments (message, errorCode, location) being null.

Please register to edit this issue

Also available in: Atom PDF