Project

Profile

Help

Bug #6256

closed

function-name returns an empty sequence for node-name#0, string#0 and more?

Added by Nico Kutscherauer 5 months ago. Updated 5 months ago.

Status:
Resolved
Priority:
Normal
Assignee:
Category:
XPath conformance
Sprint/Milestone:
-
Start date:
2023-11-20
Due date:
% Done:

0%

Estimated time:
Legacy ID:
Applies to branch:
11, 12, trunk
Fix Committed on Branch:
11, 12, trunk
Fixed in Maintenance Release:
Platforms:
.NET, Java

Description

Hi,

I was faced with a strange behavior of Saxon 12: The XPath expression function-name(node-name#0) returns an empty sequence. In oposite function-name(node-name#1) returns fn:node-name. Same for string#0, though position#0 returns fn:position as expected.

I demonstrate it in this GitHub project:

https://github.com/nkutsche/saxon-issue-function-name-zero-arg/blob/main/src/main/resources/xsl/main.xsl

Here you see the result:

https://github.com/nkutsche/saxon-issue-function-name-zero-arg/actions/runs/6934049245/job/18861459121#step:4:19

Also interesting in Saxon 11 it returned anon instead of an empty sequence. See: https://github.com/nkutsche/saxon-issue-function-name-zero-arg/actions/runs/6934049245/job/18861459121#step:5:411

Is this a desired behavior?

Best Regards, Nico

Actions #1

Updated by Michael Kay 5 months ago

  • Category set to XPath conformance
  • Assignee set to Michael Kay
  • Priority changed from Low to Normal
  • Platforms .NET, Java added

Thanks, I've added a test case to QT3 test set fn-function-name which confirms this as a bug.

The bug arises because references to context-dependent functions like fn:node-name#0 are actually compiled to an anonymous inline function with a closure, in effect let $var := . return function(){node-name($var)}, and the anonymous function of course has no function name.

Actions #2

Updated by Michael Kay 5 months ago

  • Status changed from New to Resolved
  • Applies to branch 11, 12, trunk added
  • Fix Committed on Branch 11, 12, trunk added

Fixed in ContextItemAccessorFunction.bindContext() by giving an explicit name to the constructed CallableFunction.

Actions #3

Updated by O'Neil Delpratt 5 months ago

  • Fixed in Maintenance Release 12.4 added

Bug fix applied in the Saxon 12.4 Maintenance release. Leaving it marked as 'Resolved' until fix applied on Saxon 11.

Please register to edit this issue

Also available in: Atom PDF