You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by mu...@apache.org on 2025/05/31 10:29:45 UTC

(xalan-java) branch xalan-j_xslt3.0_mvn updated: committing implementation enhancement for xsl:function where more than one xsl:function definition can be there in a stylesheet with same name but different arity

This is an automated email from the ASF dual-hosted git repository.

mukulg pushed a commit to branch xalan-j_xslt3.0_mvn
in repository https://gitbox.apache.org/repos/asf/xalan-java.git


The following commit(s) were added to refs/heads/xalan-j_xslt3.0_mvn by this push:
     new 8bc1a588e committing implementation enhancement for xsl:function where more than one xsl:function definition can be there in a stylesheet with same name but different arity
8bc1a588e is described below

commit 8bc1a588e7bb2af6ee05c4863346dbd11dc89780
Author: Mukul Gandhi <ga...@gmail.com>
AuthorDate: Sat May 31 15:59:26 2025 +0530

    committing implementation enhancement for xsl:function where more than one xsl:function definition can be there in a stylesheet with same name but different arity
---
 README                                             |   8 +-
 .../org/apache/xalan/res/XSLTErrorResources.java   |   7 +-
 .../org/apache/xalan/templates/StylesheetRoot.java |  14 +-
 .../org/apache/xalan/templates/TemplateList.java   | 208 +++++++++++++--------
 .../xalan/templates/XslFunctionDefinitionKey.java  | 101 ++++++++++
 src/main/java/org/apache/xpath/XPath.java          |   7 +-
 .../org/apache/xpath/compiler/XPathParser.java     |  86 +++++----
 .../org/apache/xpath/composite/XPathLetExpr.java   |   3 +-
 .../xpath/functions/XSL3FunctionService.java       |   3 +-
 .../apache/xpath/functions/hof/FuncFoldLeft.java   |  49 +----
 .../apache/xpath/functions/hof/FuncFoldRight.java  |  49 +----
 .../hof/XPathHigherOrderBuiltinFunction.java       |  99 ++++++++++
 .../result/decl/_character-map-test-set_result.xml |   2 +-
 .../result/decl/_function-test-set_result.xml      |  17 +-
 .../xslt3/result/expr/_axes-test-set_result.xml    |   2 +-
 .../result/expr/_castable-test-set_result.xml      |   2 +-
 .../result/expr/_expression-test-set_result.xml    |   2 +-
 .../w3c/xslt3/result/expr/_for-test-set_result.xml |   2 +-
 .../_higher-order-functions-test-set_result.xml    |   6 +-
 .../xslt3/result/expr/_math-test-set_result.xml    |   2 +-
 .../result/expr/_nodetest-test-set_result.xml      |   2 +-
 .../xslt3/result/expr/_path-test-set_result.xml    |   2 +-
 .../result/expr/_predicate-test-set_result.xml     |   2 +-
 .../result/fn/_deep-equal-test-set_result.xml      |   2 +-
 .../w3c/xslt3/result/fn/_key-test-set_result.xml   |   2 +-
 .../xslt3/result/fn/_position-test-set_result.xml  |   2 +-
 .../w3c/xslt3/result/fn/_root-test-set_result.xml  |   2 +-
 .../insn/_analyze-string-test-set_result.xml       |   2 +-
 .../insn/_apply-templates-test-set_result.xml      |   2 +-
 .../result/insn/_attribute-test-set_result.xml     |   2 +-
 .../result/insn/_call-template-test-set_result.xml |   2 +-
 .../xslt3/result/insn/_choose-test-set_result.xml  |   2 +-
 .../xslt3/result/insn/_copy-test-set_result.xml    |   2 +-
 .../xslt3/result/insn/_element-test-set_result.xml |   2 +-
 .../insn/_for-each-group-test-set_result.xml       |  16 +-
 .../xslt3/result/insn/_iterate-test-set_result.xml |   2 +-
 .../result/insn/_sequence-test-set_result.xml      |   4 +-
 .../xslt3/result/insn/_sort-test-set_result.xml    |   2 +-
 .../w3c/xslt3/result/insn/_try-test-set_result.xml |   2 +-
 .../xslt3/result/type/_boolean-test-set_result.xml |   2 +-
 .../xslt3/result/type/_node-test-set_result.xml    |   2 +-
 .../xslt3/result/type/_string-test-set_result.xml  |   2 +-
 .../result/w3c_xslt3_testsuite_xalan-j_result.xml  |  10 +-
 .../apache/xalan/tests/xslt3/XslFunctionTests.java |  10 +
 src/test/resources/xsl_function/gold/test24.out    |   4 +
 src/test/resources/xsl_function/test24.xsl         |  53 ++++++
 46 files changed, 524 insertions(+), 282 deletions(-)

diff --git a/README b/README
index 315f1a295..caf0c9c94 100644
--- a/README
+++ b/README
@@ -17,7 +17,7 @@
 
 Copyright 1999-2025 The Apache Software Foundation
 
-Document last modified : 2025-05-30
+Document last modified : 2025-05-31
 
 Authors:
    Gary Gregory <gg...@apache.org>
@@ -59,16 +59,16 @@ The Maven build results like following shall be produced:
 [INFO]  T E S T S
 [INFO] -------------------------------------------------------
 [INFO] Running org.apache.xalan.tests.main.AllXalanXSLT3Tests
-[INFO] Tests run: 1068, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 43.895 s - in org.apache.xalan.tests.main.AllXalanXSLT3Tests
+[INFO] Tests run: 1069, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 35.376 s - in org.apache.xalan.tests.main.AllXalanXSLT3Tests
 [INFO]
 [INFO] Results:
 [INFO]
-[INFO] Tests run: 1068, Failures: 0, Errors: 0, Skipped: 0
+[INFO] Tests run: 1069, Failures: 0, Errors: 0, Skipped: 0
 [INFO]
 [INFO] ------------------------------------------------------------------------
 [INFO] BUILD SUCCESS
 [INFO] ------------------------------------------------------------------------
-[INFO] Total time:  01:25 min
+[INFO] Total time:  01:43 min
 
 
 If the user needs to run Xalan-J's XSLT 3.0 implementation via Java code, the value of JVM's system property 
diff --git a/src/main/java/org/apache/xalan/res/XSLTErrorResources.java b/src/main/java/org/apache/xalan/res/XSLTErrorResources.java
index 0dcc8bbcd..c1ddaa5cc 100644
--- a/src/main/java/org/apache/xalan/res/XSLTErrorResources.java
+++ b/src/main/java/org/apache/xalan/res/XSLTErrorResources.java
@@ -105,6 +105,8 @@ public class XSLTErrorResources extends ListResourceBundle
   public static final String ER_NEED_MATCH_ATTRIB = "ER_NEED_MATCH_ATTRIB";
   public static final String ER_NEED_NAME_OR_MATCH_ATTRIB = 
 	 "ER_NEED_NAME_OR_MATCH_ATTRIB";
+  public static final String ER_XSL_FUNCTION_NEED_NAME_ATTRIB = 
+	 "ER_XSL_FUNCTION_NEED_NAME_ATTRIB";
   public static final String ER_CANT_RESOLVE_NSPREFIX =
 	 "ER_CANT_RESOLVE_NSPREFIX";
   public static final String ER_ILLEGAL_VALUE = "ER_ILLEGAL_VALUE";
@@ -551,6 +553,9 @@ public class XSLTErrorResources extends ListResourceBundle
 
     { ER_NEED_NAME_ATTRIB,
       "xsl:with-param must have a 'name' attribute."},
+    
+    { ER_XSL_FUNCTION_NEED_NAME_ATTRIB,
+      "xsl:function must have a 'name' attribute."},
 
     { ER_NO_CONTEXT_OWNERDOC,
       "context does not have an owner document!"},
@@ -800,7 +805,7 @@ public class XSLTErrorResources extends ListResourceBundle
       "Found more than one template named: {0}"},
     
     { ER_DUPLICATE_XSL_FUNCTION,
-      "Found more than one stylesheet function named: {0}"},
+      "Found more than one XSL stylesheet function named: {0} with arity {1}"},
 
     { ER_INVALID_KEY_CALL,
       "Invalid function call: recursive key() calls are not allowed"},
diff --git a/src/main/java/org/apache/xalan/templates/StylesheetRoot.java b/src/main/java/org/apache/xalan/templates/StylesheetRoot.java
index 91048e119..d4aa51d91 100644
--- a/src/main/java/org/apache/xalan/templates/StylesheetRoot.java
+++ b/src/main/java/org/apache/xalan/templates/StylesheetRoot.java
@@ -359,7 +359,7 @@ public class StylesheetRoot extends StylesheetComposed
     m_decimalFormatSymbols = new Hashtable();
     m_keyDecls = new Vector();
     m_namespaceAliasComposed = new Hashtable();
-    m_templateList = new TemplateList();
+    m_templateList = new TemplateList();    
     m_variables = new Vector();
 
     // Now we sequence through the sorted elements, 
@@ -874,6 +874,18 @@ public class StylesheetRoot extends StylesheetComposed
     return m_templateList.getTemplate(qname);
   }
   
+  /**
+   * Get an "xsl:function" property.
+   * 
+   * @param qname
+   * @param arity
+   * @return
+   */
+  public ElemFunction getXslFunction(QName qname, int arity)
+  {	  
+	  return (ElemFunction)(m_templateList.getXslFunction(qname, arity));
+  }
+  
   /**
    * Composed set of all variables and params.
    */
diff --git a/src/main/java/org/apache/xalan/templates/TemplateList.java b/src/main/java/org/apache/xalan/templates/TemplateList.java
index cb31c965c..9431b8834 100644
--- a/src/main/java/org/apache/xalan/templates/TemplateList.java
+++ b/src/main/java/org/apache/xalan/templates/TemplateList.java
@@ -21,7 +21,9 @@
 package org.apache.xalan.templates;
 
 import java.util.Enumeration;
+import java.util.HashMap;
 import java.util.Hashtable;
+import java.util.Map;
 import java.util.Vector;
 
 import javax.xml.transform.TransformerException;
@@ -39,11 +41,12 @@ import org.apache.xpath.patterns.UnionPattern;
 
 /**
  * Encapsulates a template list, and helps locate individual templates.
+ * 
  * @xsl.usage advanced
  */
 public class TemplateList implements java.io.Serializable
 {
-    static final long serialVersionUID = 5803675288911728791L;
+  static final long serialVersionUID = 5803675288911728791L;
 
   /**
    * Construct a TemplateList object. Needs to be public so it can
@@ -55,83 +58,102 @@ public class TemplateList implements java.io.Serializable
   }
 
   /**
-   * Add a template to the table of named templates and/or the table of templates
-   * with match patterns.  This routine should
-   * be called in decreasing order of precedence but it checks nonetheless.
+   * Add a template to the table of named templates, and/or the table of templates
+   * with match patterns. This method is also used to add xsl:function definitions
+   * to a table of function definitions. 
+   * 
+   * This routine should be called in decreasing order of precedence but it 
+   * checks nonetheless.
    *
-   * @param template
+   * @param template				This can be for an xsl:template definition or
+   *                                xsl:function definition.
    */
   public void setTemplate(ElemTemplate template)
-  {
-    XPath matchXPath = template.getMatch();
-    
-    if (null == template.getName() && null == matchXPath)
-    {
-      if (!(template instanceof ElemFunction)) {
-         template.error(XSLTErrorResources.ER_NEED_NAME_OR_MATCH_ATTRIB,
-                                                      new Object[]{ "xsl:template" });
-      }
-    }
-    
-    if (null != template.getName())
-    {
-      ElemTemplate existingTemplate = (ElemTemplate) m_namedTemplates.get(template.getName());
-      if (null == existingTemplate)
-      {
-        m_namedTemplates.put(template.getName(), template);
-      }
-      else
-      {
-        int existingPrecedence =
-                        existingTemplate.getStylesheetComposed().getImportCountComposed();
-        int newPrecedence = template.getStylesheetComposed().getImportCountComposed();
-        if (newPrecedence > existingPrecedence)
+  {    
+	  
+    if (!(template instanceof ElemFunction)) {    	
+    	XPath matchXPath = template.getMatch();
+    	
+    	if ((template.getName() == null) && (matchXPath == null))
         {
-          // This should never happen
-          m_namedTemplates.put(template.getName(), template);
+            template.error(XSLTErrorResources.ER_NEED_NAME_OR_MATCH_ATTRIB,
+                                                                      new Object[]{ "xsl:template" });
         }
-        else if (newPrecedence == existingPrecedence) {
-          if (template instanceof ElemFunction) {
-             template.error(XSLTErrorResources.ER_DUPLICATE_XSL_FUNCTION,
-                                             new Object[]{ template.getName() }); 
-          }
-          else {
-             template.error(XSLTErrorResources.ER_DUPLICATE_NAMED_TEMPLATE,
-                                             new Object[]{ template.getName() });
-          }
+    	
+    	if (template.getName() != null)
+        {
+    		ElemTemplate existingTemplate = (ElemTemplate)(m_namedTemplates.get(template.getName()));
+    		if (existingTemplate == null)
+    		{
+    			m_namedTemplates.put(template.getName(), template);
+    		}
+    		else {
+    			int existingPrecedence = existingTemplate.getStylesheetComposed().getImportCountComposed();
+    			int newPrecedence = template.getStylesheetComposed().getImportCountComposed();
+    			if (newPrecedence == existingPrecedence) {
+    				template.error(XSLTErrorResources.ER_DUPLICATE_NAMED_TEMPLATE,
+    																		  new Object[]{ template.getName() });
+    			}
+    		}    		
         }
-      }
-    }    
-
-    if (null != matchXPath)
-    {
-      Expression matchExpr = matchXPath.getExpression();
-      
-      XPath templateMatchXPath = template.getMatch();
-      String xpathPatternStr = templateMatchXPath.getPatternString();
-	  if (".".equals(xpathPatternStr) || xpathPatternStr.startsWith(".[")) {		 		 
-		 insertPatternInTable(String.valueOf(xpathPatternStr), template);
-	  }
-	  else if (matchExpr instanceof StepPattern)
-      {
-        insertPatternInTable((StepPattern) matchExpr, template);
-      }
-      else if (matchExpr instanceof UnionPattern)
-      {
-        UnionPattern upat = (UnionPattern) matchExpr;
-        StepPattern[] pats = upat.getPatterns();
-        int n = pats.length;
-
-        for (int i = 0; i < n; i++)
+    	
+    	if (matchXPath != null)
         {
-          insertPatternInTable(pats[i], template);
+    		Expression matchExpr = matchXPath.getExpression();
+
+    		XPath templateMatchXPath = template.getMatch();
+    		String xpathPatternStr = templateMatchXPath.getPatternString();
+    		if (".".equals(xpathPatternStr) || xpathPatternStr.startsWith(".[")) {		 		 
+    			insertPatternInTable(String.valueOf(xpathPatternStr), template);
+    		}
+    		else if (matchExpr instanceof StepPattern)
+    		{
+    			insertPatternInTable((StepPattern) matchExpr, template);
+    		}
+    		else if (matchExpr instanceof UnionPattern)
+    		{
+    			UnionPattern upat = (UnionPattern) matchExpr;
+    			StepPattern[] pats = upat.getPatterns();
+    			int n = pats.length;
+
+    			for (int i = 0; i < n; i++)
+    			{
+    				insertPatternInTable(pats[i], template);
+    			}
+    		}
         }
-      }
-      else
-      {
-        // TODO: assert error
-      }
     }
+    else {
+    	if (template.getName() == null)
+        {
+            template.error(XSLTErrorResources.ER_XSL_FUNCTION_NEED_NAME_ATTRIB,
+                                                                      new Object[]{});
+        }
+    	else {
+    		int funcArity = 0;
+    		for (ElemTemplateElement elem = template.getFirstChildElem(); elem != null; elem = elem.getNextSiblingElem()) {
+    			if (elem instanceof ElemParam) {
+    				funcArity++; 
+    			}
+    		}
+    		
+    		XslFunctionDefinitionKey funcDefnKey = new XslFunctionDefinitionKey(template.getName(), funcArity);
+    		ElemFunction existingXslFunction = m_functionDefinitionMap.get(funcDefnKey);
+    		if (existingXslFunction == null)
+    		{
+    			m_functionDefinitionMap.put(funcDefnKey, (ElemFunction)template);
+    		}
+    		else {
+    			int existingPrecedence = existingXslFunction.getStylesheetComposed().getImportCountComposed();
+    			int newPrecedence = template.getStylesheetComposed().getImportCountComposed();
+    			if (newPrecedence == existingPrecedence) {
+    				template.error(XSLTErrorResources.ER_DUPLICATE_XSL_FUNCTION,
+    																		  new Object[]{ existingXslFunction.getName(), funcDefnKey.getArity() });
+    			}
+    		}
+    	 }
+      }
+    
   }
 
 /** Flag to indicate whether in DEBUG mode          */
@@ -459,11 +481,28 @@ public class TemplateList implements java.io.Serializable
    *
    * @param qname  Qualified name of the template.
    *
-   * @return Template argument with the requested name, or null if not found.
+   * @return 	   An xsl:template definition object instance, or null 
+   *               if not found.
    */
   public ElemTemplate getTemplate(QName qname)
   {
-    return (ElemTemplate) m_namedTemplates.get(qname);
+	  return (ElemTemplate) m_namedTemplates.get(qname);
+  }
+  
+  /**
+   * Locate an XSL named function.
+   * 
+   * @param qname	Qualified name of an XSL function.
+   * @param arity	XSL function definition's arity
+   * 
+   * @return        An XSL function definition object instance, or null 
+   *                if not found.
+   */
+  public ElemTemplate getXslFunction(QName qname, int arity)
+  {
+	  XslFunctionDefinitionKey xslFunctionDefinitionKey = new XslFunctionDefinitionKey(qname, arity);
+
+	  return (ElemTemplate) (m_functionDefinitionMap.get(xslFunctionDefinitionKey));
   }
 
   /**
@@ -818,33 +857,40 @@ public class TemplateList implements java.io.Serializable
    * that are macro elements in the XSL DOM tree.
    * Initialized in initMacroLookupTable, and used in
    * findNamedTemplate.
-   * @serial
    */
   private Hashtable m_namedTemplates = new Hashtable(89);
+  
+  /**
+   * An java.util.Map object to store xsl:function definitions within an XSL stylesheet. 
+   */
+  private Map<XslFunctionDefinitionKey, ElemFunction> m_functionDefinitionMap = new HashMap<XslFunctionDefinitionKey, ElemFunction>();
 
   /**
    * This table is keyed on the target elements
    * of patterns, and contains linked lists of
    * the actual patterns that match the target element
    * to some degree of specifity.
-   * @serial
    */
   private Hashtable m_patternTable = new Hashtable(89);
 
-  /** Wildcard patterns.
-   *  @serial          */
+  /** 
+   * Wildcard patterns.
+   */
   private TemplateSubPatternAssociation m_wildCardPatterns = null;
 
-  /** Text Patterns.
-   *  @serial          */
+  /** 
+   * Text Patterns.
+   */
   private TemplateSubPatternAssociation m_textPatterns = null;
 
-  /** Root document Patterns.
-   *  @serial          */
+  /** 
+   * Root document Patterns.
+   */
   private TemplateSubPatternAssociation m_docPatterns = null;
 
-  /** Comment Patterns.
-   *  @serial          */
+  /** 
+   * Comment Patterns.
+   */
   private TemplateSubPatternAssociation m_commentPatterns = null;
 
   /**
diff --git a/src/main/java/org/apache/xalan/templates/XslFunctionDefinitionKey.java b/src/main/java/org/apache/xalan/templates/XslFunctionDefinitionKey.java
new file mode 100644
index 000000000..276b3c179
--- /dev/null
+++ b/src/main/java/org/apache/xalan/templates/XslFunctionDefinitionKey.java
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.xalan.templates;
+
+import org.apache.xml.utils.QName;
+
+/**
+ * A class definition, whose object instance uniquely identifies 
+ * an xsl:function definition.
+ * 
+ * @author Mukul Gandhi <mu...@apache.org>
+ * 
+ * @xsl.usage advanced
+ */
+public class XslFunctionDefinitionKey {
+	
+	/**
+	 * An xsl:function definition's name.
+	 */
+	private QName m_name = null;
+	
+	/**
+	 * An xsl:function definition's arity.
+	 */
+	private int m_arity;
+	
+	/**
+	 * Class constructor.
+	 * 
+	 * @param name				An xsl:function definition's name
+	 * @param arity				An xsl:function definition's arity
+	 */
+	public XslFunctionDefinitionKey(QName name, int arity) {
+		this.m_name = name;
+		this.m_arity = arity;
+	}
+
+	public QName getName() {
+		return m_name;
+	}
+
+	public void setName(QName name) {
+		this.m_name = name;
+	}
+
+	public int getArity() {
+		return m_arity;
+	}
+
+	public void setArity(int arity) {
+		this.m_arity = arity;
+	}
+	
+	public boolean equals(Object obj) {
+		boolean result = false;
+		
+		if (obj instanceof XslFunctionDefinitionKey) {
+		    XslFunctionDefinitionKey funcDefnKey = (XslFunctionDefinitionKey)obj;
+		    QName funcName = funcDefnKey.getName();
+		    int arity = funcDefnKey.getArity();
+		    if (funcName.equals(this.m_name) && (arity == this.m_arity)) {
+		       result = true;
+		    }
+		}
+		
+		return result;
+	}
+	
+	public int hashCode() {
+		int result = 0;
+		
+		int qNameHashCode = m_name.hashCode();
+		int arityHashCode = (Integer.valueOf(m_arity)).hashCode();
+		
+		long sum1 = (qNameHashCode + (long)arityHashCode);
+		if (sum1 <= Integer.MAX_VALUE) {
+			result = (int)sum1; 
+		}
+		else {
+			result = (int)(sum1 / 2); 
+		}  
+		
+		return result;
+	}
+
+}
diff --git a/src/main/java/org/apache/xpath/XPath.java b/src/main/java/org/apache/xpath/XPath.java
index 444b6f789..cf17ea66a 100644
--- a/src/main/java/org/apache/xpath/XPath.java
+++ b/src/main/java/org/apache/xpath/XPath.java
@@ -799,12 +799,7 @@ public class XPath implements Serializable, ExpressionOwner
 
 	  try {    	
 		  if (isProcessAsNodeset) {
-			  if (m_mainExp instanceof Function) {
-				  result = ((Function)m_mainExp).execute(xctxt); 
-			  }
-			  else {
-				  result = m_mainExp.execute(xctxt);
-			  }
+			  result = m_mainExp.execute(xctxt);
 		  }
 		  else {
 			  String xpathPatternStr = getPatternString();
diff --git a/src/main/java/org/apache/xpath/compiler/XPathParser.java b/src/main/java/org/apache/xpath/compiler/XPathParser.java
index 260771584..159c78a31 100644
--- a/src/main/java/org/apache/xpath/compiler/XPathParser.java
+++ b/src/main/java/org/apache/xpath/compiler/XPathParser.java
@@ -3764,53 +3764,57 @@ public class XPathParser
        nextToken();
        consumeExpected('(');
        
-       // While parsing the arguments detail of a dynamic function call,
-       // we use the code as specified below, and store the resulting
-       // information within an object of class 'DynamicFunctionCall'.
+       // XPath parse of dynamic function call argument information
        
        List<String> argList = new ArrayList<>();
        
-       List<String> argDetailsStrPartsList = new ArrayList<String>();
-       
-       // We specify here a temporary function call argument delimiter 
-       // string, for this processing.       
-       String delim = "t0_" + (UUID.randomUUID()).toString();
-       
-       while (m_token != null && isXPathDynamicFuncCallParseAhead(
-                                                      argDetailsStrPartsList, delim)) {
-          // NO OP
-       }
-       
-       m_dynamicFunctionCallArgumentMarker = false;
-       
-       int startIdx = 0;
-       int idxDelim;       
-       while (argDetailsStrPartsList.contains(delim) && 
-                         (idxDelim = argDetailsStrPartsList.indexOf(delim)) != -1) {
-          List<String> lst1 = argDetailsStrPartsList.subList(startIdx, idxDelim);
-          
-          String xpathStr = getXPathStrFromComponentParts(lst1);
-          
-          argList.add(xpathStr);
-          
-          List<String> lst2 = argDetailsStrPartsList.subList(idxDelim + 1, 
-                                                                           argDetailsStrPartsList.size());
-          
-          argDetailsStrPartsList = lst2; 
+       if (!tokenIs(')')) {
+    	   // Function call argument list is not empty
+    	   
+    	   List<String> argDetailsStrPartsList = new ArrayList<String>();
+
+    	   // We specify here a temporary function call argument delimiter 
+    	   // string, for this processing.       
+    	   String delim = "t0_" + (UUID.randomUUID()).toString();
+
+    	   while (m_token != null && isXPathDynamicFuncCallParseAhead(
+    			   argDetailsStrPartsList, delim)) {
+    		   // NO OP
+    	   }
+
+    	   m_dynamicFunctionCallArgumentMarker = false;
+
+    	   int startIdx = 0;
+    	   int idxDelim;       
+    	   while (argDetailsStrPartsList.contains(delim) && 
+    			   (idxDelim = argDetailsStrPartsList.indexOf(delim)) != -1) {
+    		   List<String> lst1 = argDetailsStrPartsList.subList(startIdx, idxDelim);
+
+    		   String xpathStr = getXPathStrFromComponentParts(lst1);
+
+    		   argList.add(xpathStr);
+
+    		   List<String> lst2 = argDetailsStrPartsList.subList(idxDelim + 1, 
+    				   argDetailsStrPartsList.size());
+
+    		   argDetailsStrPartsList = lst2; 
+    	   }
+
+    	   if (argDetailsStrPartsList.size() > 0) {
+    		   String xpathStr = getXPathStrFromComponentParts(argDetailsStrPartsList);
+    		   argList.add(xpathStr);
+    	   }
        }
        
-       if (argDetailsStrPartsList.size() > 0) {
-           String xpathStr = getXPathStrFromComponentParts(argDetailsStrPartsList);
-           argList.add(xpathStr);
-       }
-
        consumeExpected(')');
        
        XPathDynamicFunctionCall xpathDynamicFunctionCall = new XPathDynamicFunctionCall();
        xpathDynamicFunctionCall.setFuncRefVarName(funcRefVarName);
        xpathDynamicFunctionCall.setArgList(argList);
        
-       mutateXPathDynamicFuncCallReference(xpathDynamicFunctionCall, argList);              
+       if (argList.size() > 0) {
+           mutateXPathDynamicFuncCallReference(xpathDynamicFunctionCall, argList);
+       }
               
        m_xpathDynamicFunctionCallList.add(xpathDynamicFunctionCall);
        
@@ -6698,10 +6702,12 @@ public class XPathParser
 			consumeExpected(':');
 			
 			try {
-				String funcName = m_token.substring(0, m_token.indexOf('#'));
-				ElemTemplate elemTemplate = stylesheetRoot.getTemplateComposed(new org.apache.xml.utils.QName(funcNamespaceUri, funcName));
-				if (elemTemplate instanceof ElemFunction) {
-					ElemFunction elemFunction = (ElemFunction)elemTemplate;
+				int indexOfHash = m_token.indexOf('#');
+				String funcName = m_token.substring(0, indexOfHash);
+				int arity = Integer.valueOf(m_token.substring(indexOfHash + 1)); 				
+				ElemFunction elemFunction = stylesheetRoot.getXslFunction(new org.apache.xml.utils.QName(funcNamespaceUri, 
+						                                                                                               funcName), arity);
+				if (elemFunction != null) {
 					String namedFuncRef = m_token;										
 					nextToken();					
 					insertOp(opPos, 2, OpCodes.OP_NAMED_FUNCTION_REFERENCE);
diff --git a/src/main/java/org/apache/xpath/composite/XPathLetExpr.java b/src/main/java/org/apache/xpath/composite/XPathLetExpr.java
index bd0927052..64d226866 100644
--- a/src/main/java/org/apache/xpath/composite/XPathLetExpr.java
+++ b/src/main/java/org/apache/xpath/composite/XPathLetExpr.java
@@ -61,7 +61,8 @@ public class XPathLetExpr extends Expression {
     // The following two fields of this class, are used during 
     // XPath.fixupVariables(..) action as performed within object of 
     // this class.    
-    private Vector m_vars;    
+    private Vector m_vars;
+    
     private int m_globals_size;
 
     @Override
diff --git a/src/main/java/org/apache/xpath/functions/XSL3FunctionService.java b/src/main/java/org/apache/xpath/functions/XSL3FunctionService.java
index f8e7751bd..003e1a4ba 100644
--- a/src/main/java/org/apache/xpath/functions/XSL3FunctionService.java
+++ b/src/main/java/org/apache/xpath/functions/XSL3FunctionService.java
@@ -167,7 +167,8 @@ public class XSL3FunctionService {
 
     				TemplateList templateList = stylesheetRoot.getTemplateListComposed();
 
-    				ElemTemplate elemTemplate = templateList.getTemplate(new QName(funcNamespace, funcName));
+    				int argCount = funcObj.getArgCount();
+    				ElemTemplate elemTemplate = templateList.getXslFunction(new QName(funcNamespace, funcName), argCount);
 
     				if ((elemTemplate != null) && (elemTemplate instanceof ElemFunction)) {
     					// Evaluate XSL stylesheet function call
diff --git a/src/main/java/org/apache/xpath/functions/hof/FuncFoldLeft.java b/src/main/java/org/apache/xpath/functions/hof/FuncFoldLeft.java
index 914c7c5ce..27a39f6fd 100644
--- a/src/main/java/org/apache/xpath/functions/hof/FuncFoldLeft.java
+++ b/src/main/java/org/apache/xpath/functions/hof/FuncFoldLeft.java
@@ -22,22 +22,16 @@ import java.util.Map;
 import javax.xml.transform.SourceLocator;
 
 import org.apache.xalan.templates.ElemFunction;
-import org.apache.xalan.templates.ElemTemplate;
 import org.apache.xalan.templates.ElemTemplateElement;
-import org.apache.xalan.templates.StylesheetRoot;
-import org.apache.xalan.templates.TemplateList;
 import org.apache.xalan.templates.XMLNSDecl;
 import org.apache.xalan.transformer.TransformerImpl;
 import org.apache.xalan.xslt.util.XslTransformEvaluationHelper;
 import org.apache.xml.dtm.DTM;
 import org.apache.xml.dtm.DTMCursorIterator;
 import org.apache.xml.utils.QName;
-import org.apache.xpath.ExpressionNode;
 import org.apache.xpath.XPath;
 import org.apache.xpath.XPathContext;
 import org.apache.xpath.axes.LocPathIterator;
-import org.apache.xpath.functions.XSL3FunctionService;
-import org.apache.xpath.functions.XSLFunctionBuilder;
 import org.apache.xpath.objects.InlineFunctionParameter;
 import org.apache.xpath.objects.ResultSequence;
 import org.apache.xpath.objects.XMLNodeCursorImpl;
@@ -56,8 +50,6 @@ import org.apache.xpath.patterns.NodeTest;
 public class FuncFoldLeft extends XPathHigherOrderBuiltinFunction {
     
     private static final long serialVersionUID = -3772850377799360556L;
-    
-    private static XSL3FunctionService xslFunctionService = XSLFunctionBuilder.getXSLFunctionService(); 
 
     public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
     {
@@ -107,44 +99,9 @@ public class FuncFoldLeft extends XPathHigherOrderBuiltinFunction {
            foldLeftInlineFuncArg = (XPathInlineFunction)m_arg2;                                           
         }
         else if (m_arg2 instanceof NodeTest) {
-           NodeTest nodeTest = (NodeTest)m_arg2;
-           String funcNameRef = nodeTest.getLocalName();
-           String funcNamespace = nodeTest.getNamespace();
-           
-           ExpressionNode expressionNode = m_arg2.getExpressionOwner();
-           ExpressionNode stylesheetRootNode = null;
-           while (expressionNode != null) {
-        	   stylesheetRootNode = expressionNode;
-        	   expressionNode = expressionNode.exprGetParent();                     
-           }
-
-           StylesheetRoot stylesheetRoot = (StylesheetRoot)stylesheetRootNode;
+           transformerImpl = getTransformerImplFromXPathExpression(m_arg2);
            
-           if (stylesheetRoot != null) {
-        	   transformerImpl = stylesheetRoot.getTransformerImpl();  
-        	   TemplateList templateList = stylesheetRoot.getTemplateListComposed();        	   
-        	   if (xslFunctionService.isFuncArityWellFormed(funcNameRef)) {        	   
-        		   int hashCharIdx = funcNameRef.indexOf('#');
-        		   String funcNameRef2 = funcNameRef.substring(0, hashCharIdx);
-        		   ElemTemplate elemTemplate = templateList.getTemplate(new QName(funcNamespace, funcNameRef2));
-        		   if ((elemTemplate != null) && (elemTemplate instanceof ElemFunction)) {
-        			   elemFunction = (ElemFunction)elemTemplate;
-        			   int xslFuncDefnParamCount = elemFunction.getParamCount();                      
-        			   String str = funcNameRef.substring(hashCharIdx + 1);
-        			   int funcRefParamCount = (Integer.valueOf(str)).intValue();
-        			   if (funcRefParamCount != xslFuncDefnParamCount) {
-        				   throw new javax.xml.transform.TransformerException("FORG0006 : An XSL named function reference " + funcNameRef 
-        						   																			+ " cannot resolve to a function "
-        						   																			+ "definition.", srcLocator); 
-        			   }
-        		   }
-        	   }
-        	   else {
-        		   throw new javax.xml.transform.TransformerException("FORG0006 : An XSL named function reference " + funcNameRef 
-																											+ " cannot resolve to a function "
-																											+ "definition.", srcLocator);
-        	   }
-           }           
+           elemFunction = getElemFunctionFromNodeTestExpression((NodeTest)m_arg2, transformerImpl, srcLocator);          
         }
         else {
            throw new javax.xml.transform.TransformerException("FORG0006 : The third argument to function call "
@@ -197,7 +154,7 @@ public class FuncFoldLeft extends XPathHigherOrderBuiltinFunction {
 																					        				+ "parameters. Expected 2.", srcLocator); 
         	}
         }
-        else if ((elemFunction != null) && (transformerImpl != null)) {        						
+        else if (elemFunction != null) {        						
         	for (int idx = 0; idx < foldLeftFirstArgSeq.size(); idx++) {
         		ResultSequence argSequence = new ResultSequence();        		        		        		
         		if (idx == 0) {                        				    				    				
diff --git a/src/main/java/org/apache/xpath/functions/hof/FuncFoldRight.java b/src/main/java/org/apache/xpath/functions/hof/FuncFoldRight.java
index cb4e54145..f74c649d9 100644
--- a/src/main/java/org/apache/xpath/functions/hof/FuncFoldRight.java
+++ b/src/main/java/org/apache/xpath/functions/hof/FuncFoldRight.java
@@ -22,22 +22,16 @@ import java.util.Map;
 import javax.xml.transform.SourceLocator;
 
 import org.apache.xalan.templates.ElemFunction;
-import org.apache.xalan.templates.ElemTemplate;
 import org.apache.xalan.templates.ElemTemplateElement;
-import org.apache.xalan.templates.StylesheetRoot;
-import org.apache.xalan.templates.TemplateList;
 import org.apache.xalan.templates.XMLNSDecl;
 import org.apache.xalan.transformer.TransformerImpl;
 import org.apache.xalan.xslt.util.XslTransformEvaluationHelper;
 import org.apache.xml.dtm.DTM;
 import org.apache.xml.dtm.DTMCursorIterator;
 import org.apache.xml.utils.QName;
-import org.apache.xpath.ExpressionNode;
 import org.apache.xpath.XPath;
 import org.apache.xpath.XPathContext;
 import org.apache.xpath.axes.LocPathIterator;
-import org.apache.xpath.functions.XSL3FunctionService;
-import org.apache.xpath.functions.XSLFunctionBuilder;
 import org.apache.xpath.objects.InlineFunctionParameter;
 import org.apache.xpath.objects.ResultSequence;
 import org.apache.xpath.objects.XMLNodeCursorImpl;
@@ -56,8 +50,6 @@ import org.apache.xpath.patterns.NodeTest;
 public class FuncFoldRight extends XPathHigherOrderBuiltinFunction {
     
     private static final long serialVersionUID = 4675724832355053777L;
-    
-    private static XSL3FunctionService xslFunctionService = XSLFunctionBuilder.getXSLFunctionService();
 
     public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
     {
@@ -107,44 +99,9 @@ public class FuncFoldRight extends XPathHigherOrderBuiltinFunction {
            foldRightInlineFuncArg = (XPathInlineFunction)m_arg2;                                           
         }
         else if (m_arg2 instanceof NodeTest) {
-            NodeTest nodeTest = (NodeTest)m_arg2;
-            String funcNameRef = nodeTest.getLocalName();
-            String funcNamespace = nodeTest.getNamespace();
-            
-            ExpressionNode expressionNode = m_arg2.getExpressionOwner();
-            ExpressionNode stylesheetRootNode = null;
-            while (expressionNode != null) {
-         	   stylesheetRootNode = expressionNode;
-         	   expressionNode = expressionNode.exprGetParent();                     
-            }
-
-            StylesheetRoot stylesheetRoot = (StylesheetRoot)stylesheetRootNode;
+           transformerImpl = getTransformerImplFromXPathExpression(m_arg2);
             
-            if (stylesheetRoot != null) {
-         	   transformerImpl = stylesheetRoot.getTransformerImpl();  
-         	   TemplateList templateList = stylesheetRoot.getTemplateListComposed();        	   
-         	   if (xslFunctionService.isFuncArityWellFormed(funcNameRef)) {        	   
-         		   int hashCharIdx = funcNameRef.indexOf('#');
-         		   String funcNameRef2 = funcNameRef.substring(0, hashCharIdx);
-         		   ElemTemplate elemTemplate = templateList.getTemplate(new QName(funcNamespace, funcNameRef2));
-         		   if ((elemTemplate != null) && (elemTemplate instanceof ElemFunction)) {
-         			   elemFunction = (ElemFunction)elemTemplate;
-         			   int xslFuncDefnParamCount = elemFunction.getParamCount();                      
-         			   String str = funcNameRef.substring(hashCharIdx + 1);
-         			   int funcRefParamCount = (Integer.valueOf(str)).intValue();
-         			   if (funcRefParamCount != xslFuncDefnParamCount) {
-         				   throw new javax.xml.transform.TransformerException("FORG0006 : An XSL named function reference " + funcNameRef 
-         						   																						+ " cannot resolve to a function "
-         						   																						+ "definition.", srcLocator); 
-         			   }
-         		   }
-         	   }
-         	   else {
-         		   throw new javax.xml.transform.TransformerException("FORG0006 : An XSL named function reference " + funcNameRef 
- 																														+ " cannot resolve to a function "
- 																														+ "definition.", srcLocator);
-         	   }
-            }           
+           elemFunction = getElemFunctionFromNodeTestExpression((NodeTest)m_arg2, transformerImpl, srcLocator);          
         }
         else {
            throw new javax.xml.transform.TransformerException("FORG0006 : The third argument to function call "
@@ -198,7 +155,7 @@ public class FuncFoldRight extends XPathHigherOrderBuiltinFunction {
                                                                                                                   + "parameters. Expected 2.", srcLocator); 
             }
         }
-        else if ((elemFunction != null) && (transformerImpl != null)) {
+        else if (elemFunction != null) { 
            for (int idx = foldRightFirstArgSeq.size() - 1; idx >= 0; idx--) {
         	   ResultSequence argSequence = new ResultSequence();        	   
         	   argSequence.add(foldRightFirstArgSeq.item(idx));        	           	   
diff --git a/src/main/java/org/apache/xpath/functions/hof/XPathHigherOrderBuiltinFunction.java b/src/main/java/org/apache/xpath/functions/hof/XPathHigherOrderBuiltinFunction.java
index 50919f68d..06ebc638f 100644
--- a/src/main/java/org/apache/xpath/functions/hof/XPathHigherOrderBuiltinFunction.java
+++ b/src/main/java/org/apache/xpath/functions/hof/XPathHigherOrderBuiltinFunction.java
@@ -16,21 +16,33 @@
  */
 package org.apache.xpath.functions.hof;
 
+import javax.xml.transform.SourceLocator;
+
+import org.apache.xalan.templates.ElemFunction;
+import org.apache.xalan.templates.ElemTemplate;
+import org.apache.xalan.templates.StylesheetRoot;
+import org.apache.xalan.templates.TemplateList;
+import org.apache.xalan.transformer.TransformerImpl;
 import org.apache.xalan.xslt.util.XslTransformEvaluationHelper;
 import org.apache.xml.dtm.DTM;
 import org.apache.xml.dtm.DTMCursorIterator;
 import org.apache.xml.dtm.DTMManager;
+import org.apache.xml.utils.QName;
 import org.apache.xpath.Expression;
+import org.apache.xpath.ExpressionNode;
 import org.apache.xpath.XPathContext;
 import org.apache.xpath.axes.LocPathIterator;
 import org.apache.xpath.composite.XPathForExpr;
 import org.apache.xpath.composite.XPathSequenceConstructor;
 import org.apache.xpath.functions.Function3Args;
+import org.apache.xpath.functions.XSL3FunctionService;
+import org.apache.xpath.functions.XSLFunctionBuilder;
 import org.apache.xpath.objects.ResultSequence;
 import org.apache.xpath.objects.XMLNodeCursorImpl;
 import org.apache.xpath.objects.XObject;
 import org.apache.xpath.operations.Range;
 import org.apache.xpath.operations.Variable;
+import org.apache.xpath.patterns.NodeTest;
 
 import xml.xpath31.processor.types.XSUntyped;
 import xml.xpath31.processor.types.XSUntypedAtomic;
@@ -48,6 +60,8 @@ import xml.xpath31.processor.types.XSUntypedAtomic;
 public class XPathHigherOrderBuiltinFunction extends Function3Args {
     
     private static final long serialVersionUID = 5970365027214826130L;
+    
+    private XSL3FunctionService m_xslFunctionService = XSLFunctionBuilder.getXSLFunctionService();
 
     /**
      * This method, evaluates an XPath expression to produce an xdm sequence, that
@@ -146,5 +160,90 @@ public class XPathHigherOrderBuiltinFunction extends Function3Args {
 
         return resultSeq;
    }
+   
+    /**
+     * Function definition to get xsl:function's compiled object ElemFunction, 
+     * given a NodeTest expression.  
+     * 
+     * @param nodeTest							An object instance for example, constructed from XPath 
+     *                                          named function references like fn0:abc#1.
+     * @param transformerImpl					An XSL transform TransformerImpl object
+     * @param srcLocator						SourceLocator object in XPath context
+     * @return									An ElemFunction object if available, otherwise null
+     * 
+     * @throws javax.xml.transform.TransformerException
+     */
+   protected ElemFunction getElemFunctionFromNodeTestExpression(NodeTest nodeTest, TransformerImpl transformerImpl, 
+		                                                        SourceLocator srcLocator) throws javax.xml.transform.TransformerException {
+
+	   ElemFunction result = null;
+	   
+       String funcNameRef = nodeTest.getLocalName();
+       String funcNamespace = nodeTest.getNamespace();
+       
+       ExpressionNode expressionNode = m_arg2.getExpressionOwner();
+       ExpressionNode stylesheetRootNode = null;
+       while (expressionNode != null) {
+    	   stylesheetRootNode = expressionNode;
+    	   expressionNode = expressionNode.exprGetParent();                     
+       }
+
+       StylesheetRoot stylesheetRoot = (StylesheetRoot)stylesheetRootNode;
+       
+       if (stylesheetRoot != null) {
+    	   transformerImpl = stylesheetRoot.getTransformerImpl();  
+    	   TemplateList templateList = stylesheetRoot.getTemplateListComposed();        	   
+    	   if (m_xslFunctionService.isFuncArityWellFormed(funcNameRef)) {        	   
+    		   int hashCharIdx = funcNameRef.indexOf('#');
+    		   String funcNameRef2 = funcNameRef.substring(0, hashCharIdx);
+    		   int funcArity = Integer.valueOf(funcNameRef.substring(hashCharIdx + 1));        		   
+    		   ElemTemplate elemTemplate = templateList.getXslFunction(new QName(funcNamespace, funcNameRef2), funcArity);        		   
+    		   if (elemTemplate != null) {
+    			   result = (ElemFunction)elemTemplate;
+    			   int xslFuncDefnParamCount = result.getParamCount();                      
+    			   String str = funcNameRef.substring(hashCharIdx + 1);
+    			   int funcRefParamCount = (Integer.valueOf(str)).intValue();
+    			   if (funcRefParamCount != xslFuncDefnParamCount) {
+    				   throw new javax.xml.transform.TransformerException("FORG0006 : An XSL named function reference " + funcNameRef 
+    						   																			            + " cannot resolve to a function "
+    						   																			            + "definition.", srcLocator); 
+    			   }
+    		   }
+    	   }
+    	   else {
+    		   throw new javax.xml.transform.TransformerException("FORG0006 : An XSL named function reference " + funcNameRef 
+																										    + " cannot resolve to a function "
+																										    + "definition.", srcLocator);
+    	   }
+       }
+    	
+       return result;
+   }
+   
+   /**
+    * Function definition to get an XSL TransformerImpl instance, given 
+    * a supplied XPath compiled expression. 
+    * 
+    * @param expr					An XPath compiled expression
+    * @return                       TransformerImpl object instance
+    */
+   protected TransformerImpl getTransformerImplFromXPathExpression(Expression expr) {
+	   
+	   TransformerImpl transformerImpl = null;
+
+	   ExpressionNode expressionNode = expr.getExpressionOwner();
+	   ExpressionNode stylesheetRootNode = null;
+	   while (expressionNode != null) {
+		   stylesheetRootNode = expressionNode;
+		   expressionNode = expressionNode.exprGetParent();                     
+	   }
+
+	   StylesheetRoot stylesheetRoot = (StylesheetRoot)stylesheetRootNode;
+	   if (stylesheetRoot != null) {
+		   transformerImpl = stylesheetRoot.getTransformerImpl();
+	   }
+
+	   return transformerImpl; 
+   }
 
 }
diff --git a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/decl/_character-map-test-set_result.xml b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/decl/_character-map-test-set_result.xml
index 1704411e4..dd8a61bd8 100644
--- a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/decl/_character-map-test-set_result.xml
+++ b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/decl/_character-map-test-set_result.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-30T11:51:37Z" fail="12" name="character-map" pass="15" skipped="0" statusUnknown="2" totalRun="29">
+<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-31T10:16:49Z" fail="12" name="character-map" pass="15" skipped="0" statusUnknown="2" totalRun="29">
    <testResult status="pass" testName="character-map-001"/>
    <testResult status="pass" testName="character-map-002"/>
    <testResult status="pass" testName="character-map-003"/>
diff --git a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/decl/_function-test-set_result.xml b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/decl/_function-test-set_result.xml
index 29d433ad1..a88227472 100644
--- a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/decl/_function-test-set_result.xml
+++ b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/decl/_function-test-set_result.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-30T11:51:37Z" fail="28" name="function" pass="20" skipped="4" statusUnknown="18" totalRun="70">
+<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-31T10:16:47Z" fail="27" name="function" pass="21" skipped="4" statusUnknown="18" totalRun="70">
    <testResult status="fail" testName="function-0001">
       <outResult/>
    </testResult>
@@ -41,10 +41,13 @@
    <testResult status="fail" testName="function-0120b">
       <outResult>&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;out&gt;true&lt;/out&gt;</outResult>
    </testResult>
-   <testResult status="fail" testName="function-0121"/>
+   <testResult status="fail" testName="function-0121">
+      <outResult/>
+   </testResult>
    <testResult status="fail" testName="function-0122">
       <outResult>
          <errTrace>Illegal value: Q{}count-elements used for QNAME attribute: name</errTrace>
+         <errTrace>java.lang.RuntimeException: ElemTemplateElement error: xsl:function must have a name attribute.</errTrace>
       </outResult>
    </testResult>
    <testResult status="pass" testName="function-0201"/>
@@ -71,9 +74,7 @@
    </testResult>
    <testResult status="fail" testName="function-0901"/>
    <testResult status="pass" testName="function-1001"/>
-   <testResult status="fail" testName="function-1002">
-      <outResult/>
-   </testResult>
+   <testResult status="pass" testName="function-1002"/>
    <testResult status="pass" testName="function-1003"/>
    <testResult status="fail" testName="function-1004"/>
    <testResult status="fail" testName="function-1005">
@@ -84,13 +85,11 @@
    <testResult testName="function-1011"/>
    <testResult status="pass" testName="function-1012"/>
    <testResult status="fail" testName="function-1013"/>
-   <testResult status="fail" testName="function-1014">
-      <outResult/>
-   </testResult>
+   <testResult status="fail" testName="function-1014"/>
    <testResult testName="function-1015"/>
    <testResult status="fail" testName="function-1016">
       <outResult>
-         <errTrace>java.lang.RuntimeException: ElemTemplateElement error: Found more than one stylesheet function named: x:test</errTrace>
+         <errTrace>java.lang.RuntimeException: ElemTemplateElement error: Found more than one XSL stylesheet function named: x:test with arity 1</errTrace>
       </outResult>
    </testResult>
    <testResult testName="function-1017"/>
diff --git a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/expr/_axes-test-set_result.xml b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/expr/_axes-test-set_result.xml
index 110568740..6e6561a6d 100644
--- a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/expr/_axes-test-set_result.xml
+++ b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/expr/_axes-test-set_result.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-30T11:51:37Z" fail="29" name="axes" pass="172" skipped="0" statusUnknown="0" totalRun="201">
+<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-31T10:16:49Z" fail="29" name="axes" pass="172" skipped="0" statusUnknown="0" totalRun="201">
    <testResult status="pass" testName="axes-001"/>
    <testResult status="pass" testName="axes-002"/>
    <testResult status="pass" testName="axes-003"/>
diff --git a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/expr/_castable-test-set_result.xml b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/expr/_castable-test-set_result.xml
index 9f4547b9a..90ea8f8d1 100644
--- a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/expr/_castable-test-set_result.xml
+++ b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/expr/_castable-test-set_result.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-30T11:51:38Z" fail="7" name="castable" pass="0" skipped="0" statusUnknown="2" totalRun="9">
+<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-31T10:16:53Z" fail="7" name="castable" pass="0" skipped="0" statusUnknown="2" totalRun="9">
    <testResult status="fail" testName="castable-001"/>
    <testResult status="fail" testName="castable-002">
       <outResult>
diff --git a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/expr/_expression-test-set_result.xml b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/expr/_expression-test-set_result.xml
index d6579bc10..fedc2ff1b 100644
--- a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/expr/_expression-test-set_result.xml
+++ b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/expr/_expression-test-set_result.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-30T11:51:38Z" fail="0" name="expression" pass="9" skipped="0" statusUnknown="1" totalRun="10">
+<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-31T10:16:54Z" fail="0" name="expression" pass="9" skipped="0" statusUnknown="1" totalRun="10">
    <testResult status="pass" testName="expression-0101"/>
    <testResult status="pass" testName="expression-0301"/>
    <testResult status="pass" testName="expression-0302"/>
diff --git a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/expr/_for-test-set_result.xml b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/expr/_for-test-set_result.xml
index 4231f979a..075583f66 100644
--- a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/expr/_for-test-set_result.xml
+++ b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/expr/_for-test-set_result.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-30T11:51:38Z" fail="2" name="for" pass="1" skipped="0" statusUnknown="1" totalRun="4">
+<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-31T10:16:54Z" fail="2" name="for" pass="1" skipped="0" statusUnknown="1" totalRun="4">
    <testResult status="fail" testName="for-001"/>
    <testResult status="fail" testName="for-002"/>
    <testResult status="pass" testName="for-003"/>
diff --git a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/expr/_higher-order-functions-test-set_result.xml b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/expr/_higher-order-functions-test-set_result.xml
index 0d3fa0b4e..43dec8824 100644
--- a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/expr/_higher-order-functions-test-set_result.xml
+++ b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/expr/_higher-order-functions-test-set_result.xml
@@ -1,8 +1,6 @@
-<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-30T11:51:41Z" fail="19" name="higher-order-functions" pass="5" skipped="0" statusUnknown="1" totalRun="25">
+<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-31T10:17:01Z" fail="18" name="higher-order-functions" pass="6" skipped="0" statusUnknown="1" totalRun="25">
    <testResult status="fail" testName="higher-order-functions-001"/>
-   <testResult status="fail" testName="higher-order-functions-002">
-      <outResult/>
-   </testResult>
+   <testResult status="pass" testName="higher-order-functions-002"/>
    <testResult status="pass" testName="higher-order-functions-003"/>
    <testResult status="pass" testName="higher-order-functions-004"/>
    <testResult status="pass" testName="higher-order-functions-005"/>
diff --git a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/expr/_math-test-set_result.xml b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/expr/_math-test-set_result.xml
index 8d05b894e..764fad6af 100644
--- a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/expr/_math-test-set_result.xml
+++ b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/expr/_math-test-set_result.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-30T11:51:40Z" fail="32" name="math" pass="26" skipped="0" statusUnknown="90" totalRun="148">
+<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-31T10:16:56Z" fail="32" name="math" pass="26" skipped="0" statusUnknown="90" totalRun="148">
    <testResult testName="math-0101"/>
    <testResult status="fail" testName="math-0102">
       <outResult/>
diff --git a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/expr/_nodetest-test-set_result.xml b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/expr/_nodetest-test-set_result.xml
index 710d28c7d..26d5fe2dc 100644
--- a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/expr/_nodetest-test-set_result.xml
+++ b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/expr/_nodetest-test-set_result.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-30T11:51:40Z" fail="36" name="nodetest" pass="2" skipped="0" statusUnknown="0" totalRun="38">
+<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-31T10:16:58Z" fail="36" name="nodetest" pass="2" skipped="0" statusUnknown="0" totalRun="38">
    <testResult status="pass" testName="nodetest-001"/>
    <testResult status="pass" testName="nodetest-002"/>
    <testResult status="fail" testName="nodetest-003">
diff --git a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/expr/_path-test-set_result.xml b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/expr/_path-test-set_result.xml
index 6b41cf4f0..6fbb5a617 100644
--- a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/expr/_path-test-set_result.xml
+++ b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/expr/_path-test-set_result.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-30T11:51:40Z" fail="3" name="path" pass="7" skipped="0" statusUnknown="0" totalRun="10">
+<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-31T10:16:59Z" fail="3" name="path" pass="7" skipped="0" statusUnknown="0" totalRun="10">
    <testResult status="pass" testName="path-001"/>
    <testResult status="pass" testName="path-002"/>
    <testResult status="pass" testName="path-003"/>
diff --git a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/expr/_predicate-test-set_result.xml b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/expr/_predicate-test-set_result.xml
index 0765c5918..533213baf 100644
--- a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/expr/_predicate-test-set_result.xml
+++ b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/expr/_predicate-test-set_result.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-30T11:51:40Z" fail="7" name="predicate" pass="49" skipped="0" statusUnknown="1" totalRun="57">
+<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-31T10:17:00Z" fail="7" name="predicate" pass="49" skipped="0" statusUnknown="1" totalRun="57">
    <testResult status="fail" testName="predicate-001"/>
    <testResult status="fail" testName="predicate-002"/>
    <testResult status="fail" testName="predicate-003"/>
diff --git a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/fn/_deep-equal-test-set_result.xml b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/fn/_deep-equal-test-set_result.xml
index 01fcce172..986934768 100644
--- a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/fn/_deep-equal-test-set_result.xml
+++ b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/fn/_deep-equal-test-set_result.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-30T11:51:41Z" fail="0" name="deep-equal" pass="2" skipped="0" statusUnknown="0" totalRun="2">
+<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-31T10:17:06Z" fail="0" name="deep-equal" pass="2" skipped="0" statusUnknown="0" totalRun="2">
    <testResult status="pass" testName="deep-equal-001"/>
    <testResult status="pass" testName="deep-equal-002"/>
 </testrun>
diff --git a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/fn/_key-test-set_result.xml b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/fn/_key-test-set_result.xml
index 9ca979a68..64e5cde2a 100644
--- a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/fn/_key-test-set_result.xml
+++ b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/fn/_key-test-set_result.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-30T11:51:43Z" fail="3" name="key" pass="20" skipped="0" statusUnknown="2" totalRun="25">
+<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-31T10:17:09Z" fail="3" name="key" pass="20" skipped="0" statusUnknown="2" totalRun="25">
    <testResult status="pass" testName="key-001"/>
    <testResult status="fail" testName="key-002">
       <outResult/>
diff --git a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/fn/_position-test-set_result.xml b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/fn/_position-test-set_result.xml
index f94dbfe3e..0486c8832 100644
--- a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/fn/_position-test-set_result.xml
+++ b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/fn/_position-test-set_result.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-30T11:51:41Z" fail="8" name="position" pass="108" skipped="0" statusUnknown="1" totalRun="117">
+<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-31T10:17:06Z" fail="8" name="position" pass="108" skipped="0" statusUnknown="1" totalRun="117">
    <testResult status="pass" testName="position-0101"/>
    <testResult status="fail" testName="position-0102"/>
    <testResult status="fail" testName="position-0103">
diff --git a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/fn/_root-test-set_result.xml b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/fn/_root-test-set_result.xml
index 1b25ff364..78d51aa2e 100644
--- a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/fn/_root-test-set_result.xml
+++ b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/fn/_root-test-set_result.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-30T11:51:42Z" fail="4" name="root" pass="6" skipped="0" statusUnknown="0" totalRun="10">
+<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-31T10:17:09Z" fail="4" name="root" pass="6" skipped="0" statusUnknown="0" totalRun="10">
    <testResult status="fail" testName="root-0101"/>
    <testResult status="fail" testName="root-0102"/>
    <testResult status="pass" testName="root-0103"/>
diff --git a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/insn/_analyze-string-test-set_result.xml b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/insn/_analyze-string-test-set_result.xml
index e760e93dc..df5dbb31c 100644
--- a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/insn/_analyze-string-test-set_result.xml
+++ b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/insn/_analyze-string-test-set_result.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-30T11:51:29Z" fail="18" name="analyze-string" pass="33" skipped="5" statusUnknown="2" totalRun="58">
+<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-31T10:16:28Z" fail="18" name="analyze-string" pass="33" skipped="5" statusUnknown="2" totalRun="58">
    <testResult status="pass" testName="analyze-string-001"/>
    <testResult status="pass" testName="analyze-string-002"/>
    <testResult status="pass" testName="analyze-string-003"/>
diff --git a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/insn/_apply-templates-test-set_result.xml b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/insn/_apply-templates-test-set_result.xml
index 8d150cad1..3e1d51101 100644
--- a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/insn/_apply-templates-test-set_result.xml
+++ b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/insn/_apply-templates-test-set_result.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-30T11:51:30Z" fail="26" name="apply-templates" pass="22" skipped="2" statusUnknown="0" totalRun="50">
+<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-31T10:16:30Z" fail="26" name="apply-templates" pass="22" skipped="2" statusUnknown="0" totalRun="50">
    <testResult status="fail" testName="apply-templates-001">
       <outResult>&lt;?xml version="1.0" encoding="UTF-8"?&gt;&#13;
 &#13;
diff --git a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/insn/_attribute-test-set_result.xml b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/insn/_attribute-test-set_result.xml
index 989d47d89..62b53457f 100644
--- a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/insn/_attribute-test-set_result.xml
+++ b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/insn/_attribute-test-set_result.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-30T11:51:31Z" fail="12" name="attribute" pass="7" skipped="0" statusUnknown="2" totalRun="21">
+<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-31T10:16:34Z" fail="12" name="attribute" pass="7" skipped="0" statusUnknown="2" totalRun="21">
    <testResult status="fail" testName="attribute-0001"/>
    <testResult status="fail" testName="attribute-0002">
       <outResult/>
diff --git a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/insn/_call-template-test-set_result.xml b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/insn/_call-template-test-set_result.xml
index caed7b143..f694c5a3b 100644
--- a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/insn/_call-template-test-set_result.xml
+++ b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/insn/_call-template-test-set_result.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-30T11:51:32Z" fail="14" name="call-template" pass="25" skipped="1" statusUnknown="2" totalRun="42">
+<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-31T10:16:36Z" fail="14" name="call-template" pass="25" skipped="1" statusUnknown="2" totalRun="42">
    <testResult status="fail" testName="call-template-0001">
       <outResult>
          <errTrace>XPTY0004 : An error occured while evaluating an XPath expression ancestor-or-self::*.</errTrace>
diff --git a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/insn/_choose-test-set_result.xml b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/insn/_choose-test-set_result.xml
index e3eccc77c..c820dfb30 100644
--- a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/insn/_choose-test-set_result.xml
+++ b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/insn/_choose-test-set_result.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-30T11:51:32Z" fail="3" name="choose" pass="17" skipped="0" statusUnknown="4" totalRun="24">
+<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-31T10:16:37Z" fail="3" name="choose" pass="17" skipped="0" statusUnknown="4" totalRun="24">
    <testResult status="pass" testName="choose-0101"/>
    <testResult status="pass" testName="choose-0102"/>
    <testResult status="fail" testName="choose-0103"/>
diff --git a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/insn/_copy-test-set_result.xml b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/insn/_copy-test-set_result.xml
index 758035926..5fc64b7e9 100644
--- a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/insn/_copy-test-set_result.xml
+++ b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/insn/_copy-test-set_result.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-30T11:51:33Z" fail="38" name="copy" pass="16" skipped="0" statusUnknown="6" totalRun="60">
+<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-31T10:16:39Z" fail="38" name="copy" pass="16" skipped="0" statusUnknown="6" totalRun="60">
    <testResult status="fail" testName="copy-0101"/>
    <testResult status="pass" testName="copy-0102"/>
    <testResult status="fail" testName="copy-0103"/>
diff --git a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/insn/_element-test-set_result.xml b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/insn/_element-test-set_result.xml
index 5e3abdde0..667f81840 100644
--- a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/insn/_element-test-set_result.xml
+++ b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/insn/_element-test-set_result.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-30T11:51:36Z" fail="14" name="element" pass="8" skipped="0" statusUnknown="1" totalRun="23">
+<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-31T10:16:44Z" fail="14" name="element" pass="8" skipped="0" statusUnknown="1" totalRun="23">
    <testResult status="fail" testName="element-0001">
       <outResult/>
    </testResult>
diff --git a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/insn/_for-each-group-test-set_result.xml b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/insn/_for-each-group-test-set_result.xml
index 41302d992..2f1dc0b5d 100644
--- a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/insn/_for-each-group-test-set_result.xml
+++ b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/insn/_for-each-group-test-set_result.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-30T11:51:30Z" fail="30" name="for-each-group" pass="42" skipped="4" statusUnknown="2" totalRun="78">
+<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-31T10:16:31Z" fail="28" name="for-each-group" pass="44" skipped="4" statusUnknown="2" totalRun="78">
    <testResult status="pass" testName="for-each-group-001"/>
    <testResult status="skipped" xsltVersion="2.0 only"/>
    <testResult status="pass" testName="for-each-group-002"/>
@@ -96,20 +96,18 @@
    <testResult status="fail" testName="for-each-group-076">
       <outResult>&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;out&gt;&lt;group pop="5" country="italy"&gt;&lt;city country="italy" name="milan" pop="5"/&gt;&lt;/group&gt;&lt;group pop="7" country="france"&gt;&lt;city country="france" name="paris" pop="7"/&gt;&lt;/group&gt;&lt;group pop="4" country="germany"&gt;&lt;city country="germany" name="munich" pop="4"/&gt;&lt;/group&gt;&lt;group pop="2" country="france"&gt;&lt;city country="france" name="lyon" pop="2"/&gt;&lt;/group&gt;&lt;grou [...]
    </testResult>
-   <testResult status="fail" testName="for-each-group-078a">
-      <outResult/>
-   </testResult>
+   <testResult status="pass" testName="for-each-group-078a"/>
    <testResult status="fail" testName="for-each-group-078b">
       <outResult>
-         <errTrace>java.lang.ArrayIndexOutOfBoundsException: -1</errTrace>
+         <errTrace>XPST0008 : Variable 'f' has not been declared, or its declaration is not in scope.</errTrace>
+         <errTrace>Unknown error in XPath.</errTrace>
       </outResult>
    </testResult>
-   <testResult status="fail" testName="for-each-group-079a">
-      <outResult/>
-   </testResult>
+   <testResult status="pass" testName="for-each-group-079a"/>
    <testResult status="fail" testName="for-each-group-079b">
       <outResult>
-         <errTrace>java.lang.ArrayIndexOutOfBoundsException</errTrace>
+         <errTrace>XPST0008 : Variable 'f' has not been declared, or its declaration is not in scope.</errTrace>
+         <errTrace>Unknown error in XPath.</errTrace>
       </outResult>
    </testResult>
    <testResult status="pass" testName="for-each-group-080"/>
diff --git a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/insn/_iterate-test-set_result.xml b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/insn/_iterate-test-set_result.xml
index b45fe368b..12c63ca98 100644
--- a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/insn/_iterate-test-set_result.xml
+++ b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/insn/_iterate-test-set_result.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-30T11:51:34Z" fail="27" name="iterate" pass="9" skipped="0" statusUnknown="8" totalRun="44">
+<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-31T10:16:41Z" fail="27" name="iterate" pass="9" skipped="0" statusUnknown="8" totalRun="44">
    <testResult status="pass" testName="iterate-001"/>
    <testResult status="pass" testName="iterate-002"/>
    <testResult status="pass" testName="iterate-003"/>
diff --git a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/insn/_sequence-test-set_result.xml b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/insn/_sequence-test-set_result.xml
index b24a08c33..65ac8cd83 100644
--- a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/insn/_sequence-test-set_result.xml
+++ b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/insn/_sequence-test-set_result.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-30T11:51:34Z" fail="19" name="sequence" pass="7" skipped="0" statusUnknown="1" totalRun="27">
+<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-31T10:16:42Z" fail="18" name="sequence" pass="8" skipped="0" statusUnknown="1" totalRun="27">
    <testResult status="fail" testName="sequence-0101"/>
    <testResult status="fail" testName="sequence-0102"/>
    <testResult status="pass" testName="sequence-0103"/>
@@ -38,7 +38,7 @@
    <testResult status="pass" testName="sequence-0117"/>
    <testResult status="pass" testName="sequence-0118"/>
    <testResult status="fail" testName="sequence-0119"/>
-   <testResult status="fail" testName="sequence-0120"/>
+   <testResult status="pass" testName="sequence-0120"/>
    <testResult status="pass" testName="sequence-0121"/>
    <testResult status="fail" testName="sequence-0122"/>
    <testResult status="fail" testName="sequence-0123"/>
diff --git a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/insn/_sort-test-set_result.xml b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/insn/_sort-test-set_result.xml
index 49acc6571..613105323 100644
--- a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/insn/_sort-test-set_result.xml
+++ b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/insn/_sort-test-set_result.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-30T11:51:37Z" fail="37" name="sort" pass="31" skipped="0" statusUnknown="12" totalRun="80">
+<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-31T10:16:45Z" fail="37" name="sort" pass="31" skipped="0" statusUnknown="12" totalRun="80">
    <testResult status="pass" testName="sort-001"/>
    <testResult status="pass" testName="sort-002"/>
    <testResult testName="sort-003"/>
diff --git a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/insn/_try-test-set_result.xml b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/insn/_try-test-set_result.xml
index 37ff89b9d..9df674ccc 100644
--- a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/insn/_try-test-set_result.xml
+++ b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/insn/_try-test-set_result.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-30T11:51:30Z" fail="21" name="try" pass="11" skipped="5" statusUnknown="5" totalRun="42">
+<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-31T10:16:33Z" fail="21" name="try" pass="11" skipped="5" statusUnknown="5" totalRun="42">
    <testResult status="pass" testName="try-001"/>
    <testResult status="fail" testName="try-002">
       <outResult/>
diff --git a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/type/_boolean-test-set_result.xml b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/type/_boolean-test-set_result.xml
index 6bcf26b63..6b772836f 100644
--- a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/type/_boolean-test-set_result.xml
+++ b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/type/_boolean-test-set_result.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-30T11:51:41Z" fail="23" name="boolean" pass="89" skipped="0" statusUnknown="0" totalRun="112">
+<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-31T10:17:01Z" fail="23" name="boolean" pass="89" skipped="0" statusUnknown="0" totalRun="112">
    <testResult status="pass" testName="boolean-001"/>
    <testResult status="pass" testName="boolean-002"/>
    <testResult status="pass" testName="boolean-003"/>
diff --git a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/type/_node-test-set_result.xml b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/type/_node-test-set_result.xml
index a26b5253f..1c306836f 100644
--- a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/type/_node-test-set_result.xml
+++ b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/type/_node-test-set_result.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-30T11:51:41Z" fail="17" name="node" pass="15" skipped="0" statusUnknown="0" totalRun="32">
+<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-31T10:17:03Z" fail="17" name="node" pass="15" skipped="0" statusUnknown="0" totalRun="32">
    <testResult status="pass" testName="node-0101"/>
    <testResult status="pass" testName="node-0201"/>
    <testResult status="fail" testName="node-0301">
diff --git a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/type/_string-test-set_result.xml b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/type/_string-test-set_result.xml
index 5a5856ffc..b1a916c4d 100644
--- a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/type/_string-test-set_result.xml
+++ b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/type/_string-test-set_result.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-30T11:51:41Z" fail="6" name="string" pass="128" skipped="0" statusUnknown="2" totalRun="136">
+<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2025-05-31T10:17:04Z" fail="6" name="string" pass="128" skipped="0" statusUnknown="2" totalRun="136">
    <testResult status="pass" testName="string-001"/>
    <testResult status="pass" testName="string-002"/>
    <testResult status="pass" testName="string-003"/>
diff --git a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/w3c_xslt3_testsuite_xalan-j_result.xml b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/w3c_xslt3_testsuite_xalan-j_result.xml
index 1bafd3621..aceee37ce 100644
--- a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/w3c_xslt3_testsuite_xalan-j_result.xml
+++ b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/w3c_xslt3_testsuite_xalan-j_result.xml
@@ -1,15 +1,15 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<testResult dateTime="2025-05-30T11:51:52Z" desc="W3C XSLT 3.0 test suite results" fail="495" pass="902" skipped="21" success="58.27%" totalRun="1584" xslt_processor="Xalan-J XSLT 3.0 development code">
+<testResult dateTime="2025-05-31T10:17:19Z" desc="W3C XSLT 3.0 test suite results" fail="490" pass="907" skipped="21" success="58.59%" totalRun="1584" xslt_processor="Xalan-J XSLT 3.0 development code">
   <decl>
     <character-map fail="12" pass="15" skipped="0" success="51.72%" totalRun="29"/>
-    <function fail="28" pass="20" skipped="4" success="34.29%" totalRun="70"/>
+    <function fail="27" pass="21" skipped="4" success="35.71%" totalRun="70"/>
   </decl>
   <expr>
     <axes fail="29" pass="172" skipped="0" success="85.57%" totalRun="201"/>
     <castable fail="7" pass="0" skipped="0" success="0.0%" totalRun="9"/>
     <expression fail="0" pass="9" skipped="0" success="90.0%" totalRun="10"/>
     <for fail="2" pass="1" skipped="0" success="25.0%" totalRun="4"/>
-    <higher-order-functions fail="19" pass="5" skipped="0" success="20.0%" totalRun="25"/>
+    <higher-order-functions fail="18" pass="6" skipped="0" success="24.0%" totalRun="25"/>
     <math fail="32" pass="26" skipped="0" success="17.57%" totalRun="148"/>
     <nodetest fail="36" pass="2" skipped="0" success="5.26%" totalRun="38"/>
     <path fail="3" pass="7" skipped="0" success="70.0%" totalRun="10"/>
@@ -29,9 +29,9 @@
     <choose fail="3" pass="17" skipped="0" success="70.83%" totalRun="24"/>
     <copy fail="38" pass="16" skipped="0" success="26.67%" totalRun="60"/>
     <element fail="14" pass="8" skipped="0" success="34.78%" totalRun="23"/>
-    <for-each-group fail="30" pass="42" skipped="4" success="58.97%" totalRun="78"/>
+    <for-each-group fail="28" pass="44" skipped="4" success="61.54%" totalRun="78"/>
     <iterate fail="27" pass="9" skipped="0" success="20.45%" totalRun="44"/>
-    <sequence fail="19" pass="7" skipped="0" success="25.93%" totalRun="27"/>
+    <sequence fail="18" pass="8" skipped="0" success="29.63%" totalRun="27"/>
     <sort fail="37" pass="31" skipped="0" success="38.75%" totalRun="80"/>
     <try fail="21" pass="11" skipped="5" success="38.1%" totalRun="42"/>
   </insn>
diff --git a/src/test/java/org/apache/xalan/tests/xslt3/XslFunctionTests.java b/src/test/java/org/apache/xalan/tests/xslt3/XslFunctionTests.java
index 43429c419..fad11fd47 100644
--- a/src/test/java/org/apache/xalan/tests/xslt3/XslFunctionTests.java
+++ b/src/test/java/org/apache/xalan/tests/xslt3/XslFunctionTests.java
@@ -278,5 +278,15 @@ public class XslFunctionTests extends XslTransformTestsUtil {
         
         runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
     }
+    
+    @Test
+    public void xslFunctionTest24() {
+        String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test24.xsl"; 
+        String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test24.xsl";
+        
+        String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test24.out";                
+        
+        runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+    }
 
 }
diff --git a/src/test/resources/xsl_function/gold/test24.out b/src/test/resources/xsl_function/gold/test24.out
new file mode 100644
index 000000000..120894c8d
--- /dev/null
+++ b/src/test/resources/xsl_function/gold/test24.out
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?><result>
+  <one>3</one>
+  <two>7</two>
+</result>
diff --git a/src/test/resources/xsl_function/test24.xsl b/src/test/resources/xsl_function/test24.xsl
new file mode 100644
index 000000000..97d088075
--- /dev/null
+++ b/src/test/resources/xsl_function/test24.xsl
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                xmlns:xs="http://www.w3.org/2001/XMLSchema"
+                xmlns:fn0="http://local/"
+                exclude-result-prefixes="xs fn0"
+                version="3.0">
+                
+    <!-- Author: mukulg@apache.org -->
+    
+    <!-- An XSL stylesheet test case, to test stylesheet having more than 
+         one xsl:function definition with same name but different by arity. -->                
+				
+    <xsl:output method="xml" indent="yes"/>				
+    
+    <xsl:function name="fn0:incr" as="xs:integer">
+       <xsl:param name="x" as="xs:integer"/>
+       <xsl:sequence select="$x + 1"/>
+    </xsl:function>
+	
+	<xsl:function name="fn0:incr" as="xs:integer">
+      <xsl:sequence select="5 + 2"/>
+    </xsl:function>
+    
+    <xsl:template match="/">
+       <result>
+          <one>
+		    <xsl:value-of select="fn0:incr(2)"/>
+		  </one>
+		  <two>
+		    <xsl:value-of select="fn0:incr()"/>
+		  </two>
+       </result>	   
+    </xsl:template>
+    
+    <!--
+      * Licensed to the Apache Software Foundation (ASF) under one
+      * or more contributor license agreements. See the NOTICE file
+      * distributed with this work for additional information
+      * regarding copyright ownership. The ASF licenses this file
+      * to you under the Apache License, Version 2.0 (the "License");
+      * you may not use this file except in compliance with the License.
+      * You may obtain a copy of the License at
+      *
+      *     http://www.apache.org/licenses/LICENSE-2.0
+      *
+      * Unless required by applicable law or agreed to in writing, software
+      * distributed under the License is distributed on an "AS IS" BASIS,
+      * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+      * See the License for the specific language governing permissions and
+      * limitations under the License.
+    -->
+    
+</xsl:stylesheet>


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xalan.apache.org
For additional commands, e-mail: commits-help@xalan.apache.org