Project

Profile

Help

Bug #6605

closed

Query using static-base-uri() compiled from string gives saxonche.PySaxonApiError: NullPointer exception found: java.lang.NullPointerException

Added by Martin Honnen 15 days ago. Updated 11 days ago.

Status:
Resolved
Priority:
Normal
Category:
Python API
Start date:
2024-12-07
Due date:
% Done:

100%

Estimated time:
Applies to branch:
12, trunk
Fix Committed on Branch:
12, trunk
Fixed in Maintenance Release:
Found in version:
Fixed in version:
SaxonC Languages:
All
SaxonC Platforms:
All
SaxonC Architecture:

Description

The Python program

from saxonche import *

from pathlib import Path

xquery1 = '"Static base uri : " || static-base-uri()'

with PySaxonProcessor() as saxon_proc:
    print(saxon_proc.version)

    xqueryProcessor = saxon_proc.new_xquery_processor()

    workingDirPath = str(Path.cwd().absolute())

    print(workingDirPath)

    xqueryProcessor.set_cwd(workingDirPath)

    result = xqueryProcessor.run_query_to_string(query_text=xquery1)

    print(result)

crashes for me under both Windows and Linux.

Using the command Query I can run such a query, however, so the bug might be related to xqueryProcessor.set_cwd not working as intended.

Output on Windows:

Traceback (most recent call last):
  File "C:\Users\marti\PycharmProjects\SaxonC12CompileXsltFromStringTest1\compileXQueryFromStringTest3.py", line 18, in <module>
    result = xqueryProcessor.run_query_to_string(query_text=xquery1)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "python_saxon\saxonc.pyx", line 3028, in saxonche.PyXQueryProcessor.run_query_to_string
saxonche.PySaxonApiError: NullPointer exception found: java.lang.NullPointerException
	at java.base@11.0.18/java.util.Objects.requireNonNull(Objects.java:221)
	at net.sf.saxon.str.StringView.<init>(StringView.java:26)
	at net.sf.saxon.str.StringView.tidy(StringView.java:39)
	at net.sf.saxon.value.AnyURIValue.<init>(AnyURIValue.java:48)
	at net.sf.saxon.functions.StaticBaseUri.makeFunctionCall(StaticBaseUri.java:31)
	at net.sf.saxon.functions.registry.BuiltInFunctionSet.bind(BuiltInFunctionSet.java:246)
	at net.sf.saxon.functions.FunctionLibraryList.bind(FunctionLibraryList.java:133)
	at net.sf.saxon.expr.parser.XPathParser.parseFunctionCall(XPathParser.java:4132)
	at net.sf.saxon.expr.parser.XPathParser.parseBasicStep(XPathParser.java:2865)
	at net.sf.saxon.expr.parser.XPathParser.parseStepExpression(XPathParser.java:2633)
	at net.sf.saxon.expr.parser.XPathParser.parseRelativePath(XPathParser.java:2552)
	at net.sf.saxon.expr.parser.XPathParser.parsePathExpression(XPathParser.java:2514)
	at net.sf.saxon.expr.parser.XPathParser.parseSimpleMappingExpression(XPathParser.java:2528)
	at net.sf.saxon.expr.parser.XPathParser.parseUnaryExpression(XPathParser.java:2378)
	at net.sf.saxon.expr.parser.XPathParser.parseBinaryExpression(XPathParser.java:977)
	at net.sf.saxon.expr.parser.XPathParser.parseExprSingle(XPathParser.java:861)
	at net.sf.saxon.expr.parser.XPathParser.parseExpression(XPathParser.java:759)
	at net.sf.saxon.query.XQueryParser.parseQuery(XQueryParser.java:381)
	at net.sf.saxon.query.XQueryParser.makeXQueryExpression(XQueryParser.java:171)
	at net.sf.saxon.query.StaticQueryContext.compileQuery(StaticQueryContext.java:569)
	at net.sf.saxon.s9api.XQueryCompiler.compile(XQueryCompiler.java:651)
	at net.sf.saxon.option.cpp.XQueryEngine.xqueryEvaluator(XQueryEngine.java:202)
	at net.sf.saxon.option.cpp.XQueryEngine.executeQueryToString(XQueryEngine.java:302)
. Line number: -1
SaxonC-HE 12.5 from Saxonica
C:\Users\marti\PycharmProjects\SaxonC12CompileXsltFromStringTest1

Output on Linux:

SaxonC-HE 12.5 from Saxonica
/mnt/c/Users/marti/PycharmProjects/SaxonC12CompileXsltFromStringTest1
Traceback (most recent call last):
  File "/mnt/c/Users/marti/PycharmProjects/SaxonC12CompileXsltFromStringTest1/compileXQueryFromStringTest3.py", line 18, in <module>
    result = xqueryProcessor.run_query_to_string(query_text=xquery1)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "python_saxon/saxonc.pyx", line 3028, in saxonche.PyXQueryProcessor.run_query_to_string
saxonche.PySaxonApiError: NullPointer exception found: java.lang.NullPointerException
        at java.base@11.0.18/java.util.Objects.requireNonNull(Objects.java:221)
        at net.sf.saxon.str.StringView.<init>(StringView.java:26)
        at net.sf.saxon.str.StringView.tidy(StringView.java:39)
        at net.sf.saxon.value.AnyURIValue.<init>(AnyURIValue.java:48)
        at net.sf.saxon.functions.StaticBaseUri.makeFunctionCall(StaticBaseUri.java:31)
        at net.sf.saxon.functions.registry.BuiltInFunctionSet.bind(BuiltInFunctionSet.java:246)
        at net.sf.saxon.functions.FunctionLibraryList.bind(FunctionLibraryList.java:133)
        at net.sf.saxon.expr.parser.XPathParser.parseFunctionCall(XPathParser.java:4132)
        at net.sf.saxon.expr.parser.XPathParser.parseBasicStep(XPathParser.java:2865)
        at net.sf.saxon.expr.parser.XPathParser.parseStepExpression(XPathParser.java:2633)
        at net.sf.saxon.expr.parser.XPathParser.parseRelativePath(XPathParser.java:2552)
        at net.sf.saxon.expr.parser.XPathParser.parsePathExpression(XPathParser.java:2514)
        at net.sf.saxon.expr.parser.XPathParser.parseSimpleMappingExpression(XPathParser.java:2528)
        at net.sf.saxon.expr.parser.XPathParser.parseUnaryExpression(XPathParser.java:2378)
        at net.sf.saxon.expr.parser.XPathParser.parseBinaryExpression(XPathParser.java:977)
        at net.sf.saxon.expr.parser.XPathParser.parseExprSingle(XPathParser.java:861)
        at net.sf.saxon.expr.parser.XPathParser.parseExpression(XPathParser.java:759)
        at net.sf.saxon.query.XQueryParser.parseQuery(XQueryParser.java:381)
        at net.sf.saxon.query.XQueryParser.makeXQueryExpression(XQueryParser.java:171)
        at net.sf.saxon.query.StaticQueryContext.compileQuery(StaticQueryContext.java:569)
        at net.sf.saxon.s9api.XQueryCompiler.compile(XQueryCompiler.java:651)
        at net.sf.saxon.option.cpp.XQueryEngine.xqueryEvaluator(XQueryEngine.java:202)
        at net.sf.saxon.option.cpp.XQueryEngine.executeQueryToString(XQueryEngine.java:302)
. Line number: -1

Files

compileXQueryFromStringTest3.py (459 Bytes) compileXQueryFromStringTest3.py Martin Honnen, 2024-12-07 14:38

Related issues

Related to SaxonC - Bug #6606: With XPath, although cwd is set, static-base-uri() is emptyResolvedO'Neil Delpratt2024-12-07

Actions

Please register to edit this issue

Also available in: Atom PDF