Project

Profile

Help

Bug #6606

closed

With XPath, although cwd is set, static-base-uri() is empty

Added by Martin Honnen 15 days ago. Updated 10 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 using SaxonC HE 12.5

from saxonche import *

from pathlib import Path

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

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

    xpathProcessor = saxon_proc.new_xpath_processor()

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

    print(workingDirPath)

    xpathProcessor.set_cwd(workingDirPath)

    result = xpathProcessor.evaluate(xquery1)

    print(result)

prints out static base URI as empty although I use xpathProcessor.set_cwd(workingDirPath) to attempt to set it.

Output:

SaxonC-HE 12.5 from Saxonica
C:\Users\marti\PycharmProjects\SaxonC12CompileXsltFromStringTest1
Static base uri :

Files

evaluateXPathFromStringTest1.py (433 Bytes) evaluateXPathFromStringTest1.py Martin Honnen, 2024-12-07 15:17

Related issues

Related to SaxonC - Bug #6605: Query using static-base-uri() compiled from string gives saxonche.PySaxonApiError: NullPointer exception found: java.lang.NullPointerExceptionResolvedO'Neil Delpratt2024-12-07

Actions
Actions #1

Updated by Martin Honnen 15 days ago

I also see the empty result from string provided XPath in the C++ API e.g. code like

	std::cout << "Testing static-base-uri function from XPathProcessor" << std::endl;

	XPathProcessor* xpathProcessor = saxonProc->newXPathProcessor();

	xpathProcessor->setcwd(std::filesystem::current_path().string().c_str());

	try {

		XdmItem* item = xpathProcessor->evaluateSingle("'static base URI in XPath is: ' || static-base-uri()");

		std::cout << item->getStringValue() << std::endl;

	}
	catch (SaxonApiException& exception) {
		std::cout << "Exception: " << exception.what() << std::endl;
	}

outputs nothing for the static base URI:

Testing static-base-uri function from XPathProcessor
static base URI in XPath is:
Actions #2

Updated by O'Neil Delpratt 11 days ago

  • Status changed from New to In Progress
  • Applies to branch trunk added
  • SaxonC Languages All added

Thanks for reporting this issue. I have reproduced it and investigating it further.

Actions #3

Updated by O'Neil Delpratt 10 days ago

  • Related to Bug #6605: Query using static-base-uri() compiled from string gives saxonche.PySaxonApiError: NullPointer exception found: java.lang.NullPointerException added
Actions #4

Updated by O'Neil Delpratt 10 days ago

  • Status changed from In Progress to Resolved
  • % Done changed from 0 to 100
  • Fix Committed on Branch 12, trunk added

This issue is similar to #6605 - set the base uri on the XPath compiler. Fixed and available for the next maintenance release.

Please register to edit this issue

Also available in: Atom PDF