Project

Profile

Help

Bug #4045

closed

Null pointer exception when compiling stylesheet with template containing specific XSLT instructions

Added by Philip Fearon over 3 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Internals
Sprint/Milestone:
-
Start date:
2018-11-21
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
9.9
Fix Committed on Branch:
9.9
Fixed in Maintenance Release:
Platforms:

Description

Using Saxon 9.9.0.2 professional (java), the attached saxon9902issue.xsl stylesheet fails to compile, producing the following stack trace. With Saxon 9.9.0.1, no exception is thrown.

java.lang.NullPointerException
	at net.sf.saxon.expr.Expression.getRetainedStaticContext(Expression.java:461)
	at net.sf.saxon.expr.parser.LoopLifter.process(LoopLifter.java:50)
	at net.sf.saxon.expr.parser.ExpressionTool.optimizeComponentBody(ExpressionTool.java:1216)
	at net.sf.saxon.style.XSLTemplate.optimize(XSLTemplate.java:1054)
	at net.sf.saxon.style.PrincipalStylesheetModule.optimizeTopLevel(PrincipalStylesheetModule.java:1446)
	at net.sf.saxon.style.PrincipalStylesheetModule.compile(PrincipalStylesheetModule.java:1267)
	at net.sf.saxon.style.Compilation.compilePackage(Compilation.java:329)
	at net.sf.saxon.style.StylesheetModule.loadStylesheet(StylesheetModule.java:258)
	at net.sf.saxon.style.Compilation.compileSingletonPackage(Compilation.java:107)
	at net.sf.saxon.s9api.XsltCompiler.compile(XsltCompiler.java:778)
	at net.sf.saxon.Transform.doTransform(Transform.java:730)
	at net.sf.saxon.Transform.main(Transform.java:80)
Fatal error during transformation: java.lang.NullPointerException:  (no message)

This issue can be reproduced using both the command-line interface or the Java API


Files

saxon9902issue.xsl (1006 Bytes) saxon9902issue.xsl Philip Fearon, 2018-11-21 14:05
Actions #1

Updated by Michael Kay over 3 years ago

  • Category set to Internals
  • Status changed from New to Resolved
  • Assignee set to Michael Kay
  • Priority changed from Low to Normal
  • Fix Committed on Branch 9.9 added

Thanks for reporting it.

As a workaround, you can change the template whose body is <xsl:copy/> to <xsl:copy-of select="."/> (it's Saxon's attempt to do this rewrite that is the immediate cause of the trouble.)

Saxon uses a bit of a belt-and-braces approach to ensuring that the expression tree remains consistent, in particular that static context and location information is always retained across tree rewrites. In this case both the belt and the braces failed. (a) we had to copy the template body because it applies to more than one mode, (b) the instruction being copied is rewritten during the typechecking phase, (c) the CopyOf instruction, when copied, doesn't explicitly copy across the location information, (c) the ContextItemExpression created by Copy.typeCheck() isn't given any location information. Fixing either (c) or (d) would solve the problem and I have fixed both.

Actions #2

Updated by O'Neil Delpratt over 3 years ago

  • % Done changed from 0 to 100
  • Fixed in Maintenance Release 9.9.1.1 added

Bug fix applied to the Saxon 9.9.1.1 maintenance release.

Actions #3

Updated by O'Neil Delpratt over 3 years ago

  • Status changed from Resolved to Closed

Please register to edit this issue

Also available in: Atom PDF