Bug #4688

EE strange function parameter overriding

Added by Andy Yar about 1 year ago. Updated about 1 year ago.

XPath conformance
Start date:
Due date:
% Done:


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


Hello, during an internal Saxon upgrade to regression testing we have found out a strange issue. Our custom functions suddenly started to behave odd.

Using following snippet, the output should mimic the standard format-number(). Thus it should format value1 and value2 using the mask given as second parameter of the function call. However, this doesn't seem to be the case using EE

The whole transformation file is attached as test2.xsl.

 <xsl:template match="root">
                <xsl:value-of select="f:format-number(value1, '000')"/>
                <xsl:value-of select="f:format-number(value2, '0000000000')"/>


The output contains both value1 and value2 formatted as both were using the second mask of the parameter call.


For example, using PE seems to handle the parameter passing correctly:


Since there are numerous differences in both Saxon configurations, both attached outputs (fail.xml and correct.xml) contain a full environment printout. These particular test outputs were obtained using a copy of Oxygen IDE.

Is this a known issue? Thanks

fail.xml (8.27 KB) fail.xml Wrong output - format1 using not the first parameter 000 but the second one Andy Yar, 2020-08-17 16:17
correct.xml (8.26 KB) correct.xml Correct output - format1 using correct parameter 000 Andy Yar, 2020-08-17 16:17
format.xml (107 Bytes) format.xml Dummy test data Andy Yar, 2020-08-17 16:17
test2.xsl (2.52 KB) test2.xsl Two calls of a custom fuction Andy Yar, 2020-08-17 16:17


#1 Updated by Michael Kay about 1 year ago

Thanks for reporting it.

It's something to do with function inlining - it goes away when you run with -opt:-f, which suppresses function inlining.

#2 Updated by Michael Kay about 1 year ago

  • Status changed from New to In Progress
  • Assignee set to Michael Kay

It also goes away when you run with -explain, which I don't think I've ever seen before!

#3 Updated by Michael Kay about 1 year ago

Looks like this is essentially the same problem as bug #4549, but this time with the format-number() function rather than the key() function.

#4 Updated by Michael Kay about 1 year ago

Fixed in the same way as for #4549: make FormatNumber implement StatefulSystemFunction, and give it a copy() method.

#5 Updated by Michael Kay about 1 year ago

  • Category set to XPath conformance
  • Status changed from In Progress to Resolved
  • Applies to branch 10, 9.9, trunk added
  • Applies to branch deleted (9.7)
  • Fix Committed on Branch 10, 9.9, trunk added

Fix committed to 9.9, 10.x, and trunk.

Test case format-number-070 added to XSLT3 test suite.

#6 Updated by Andy Yar about 1 year ago

I can confirm the -opt:-f works as a workaround. Many thanks

#7 Updated by O'Neil Delpratt about 1 year ago

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

Bug fix applied in the Saxon 10.2 maintenance release.

#8 Updated by Andy Yar about 1 year ago

Hello O'Neil Delpratt and Michael Kay,

Do you plan to release a maintenance release including this fix also for the 9.9.x branch?

Thank you!

#9 Updated by Michael Kay about 1 year ago

We've been continuing to apply patches to the 9.9 branch for significant bugs, but we don't have any scheduled date for another maintenance release on that branch; it's usually triggered either by the number of outstanding bugs to be fixed, or by a customer situation where someone has a good reason for not moving forward, and no simple workaround is available.

#10 Updated by O'Neil Delpratt about 1 year ago

  • Status changed from Resolved to Closed
  • Fixed in Maintenance Release added

Bug fix applied on the Saxon maintenance release.

Please register to edit this issue

Also available in: Atom PDF