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/02/13 00:23:16 UTC

(xalan-java) branch xalan-j_xslt3.0_mvn updated: improving error handling code when doing xpath3 map lookup with function call syntax

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 75d4cc183 improving error handling code when doing xpath3 map lookup with function call syntax
75d4cc183 is described below

commit 75d4cc183a4b59ba3fab67506f9dcdc7151def03
Author: Mukul Gandhi <ga...@gmail.com>
AuthorDate: Thu Feb 13 05:52:55 2025 +0530

    improving error handling code when doing xpath3 map lookup with function call syntax
---
 .../xpath/functions/XPathDynamicFunctionCall.java    | 20 +++++++++++++++++---
 .../apache/xpath/functions/XSLFunctionService.java   |  5 +++--
 2 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/src/main/java/org/apache/xpath/functions/XPathDynamicFunctionCall.java b/src/main/java/org/apache/xpath/functions/XPathDynamicFunctionCall.java
index cc500fcff..116db166b 100644
--- a/src/main/java/org/apache/xpath/functions/XPathDynamicFunctionCall.java
+++ b/src/main/java/org/apache/xpath/functions/XPathDynamicFunctionCall.java
@@ -256,10 +256,24 @@ public class XPathDynamicFunctionCall extends Expression {
 
      				  XObject argValue = argXPath.execute(xctxt, contextNode, xctxt.getNamespaceContext());
      				  if (argValue instanceof XString) {
-     					  argValue = new XSString(((XString)argValue).str());  
+     					  argValue = new XSString(((XString)argValue).str());
+     					  evalResult = xpathMap.get(argValue);     					 
+     					  if (evalResult == null) {
+     						  throw new javax.xml.transform.TransformerException("XPTY0004 : XDM map doesn't have an entry with key name '" + 
+     								                                                              XslTransformEvaluationHelper.getStrVal(argValue) + "'.",  xctxt.getSAXLocator()); 
+     					  }
+     				  }
+     				  else if (argValue instanceof XSString) {
+     					  evalResult = xpathMap.get(argValue);     					 
+     					  if (evalResult == null) {
+     						  throw new javax.xml.transform.TransformerException("XPTY0004 : XDM map doesn't have an entry with key name '" + 
+     								                                                             XslTransformEvaluationHelper.getStrVal(argValue) + "'.",  xctxt.getSAXLocator()); 
+     					  } 
+     				  }
+     				  else {
+     					  throw new javax.xml.transform.TransformerException("XPTY0004 : XDM map lookup is not done with a "
+     							                                                                + "string valued key.",  xctxt.getSAXLocator());
      				  }
-
-     				  evalResult = xpathMap.get(argValue);
      			  }
      		   }    		   
      	    }
diff --git a/src/main/java/org/apache/xpath/functions/XSLFunctionService.java b/src/main/java/org/apache/xpath/functions/XSLFunctionService.java
index a48bff5b9..a7a8377eb 100644
--- a/src/main/java/org/apache/xpath/functions/XSLFunctionService.java
+++ b/src/main/java/org/apache/xpath/functions/XSLFunctionService.java
@@ -371,9 +371,10 @@ public class XSLFunctionService {
 	    				}
     			    }
     			    catch (Exception ex) {
+    			       String exceptionMesgStr = (ex.getMessage() != null) ? ex.getMessage() : "";
+    			       exceptionMesgStr = exceptionMesgStr.equals("") ? "" : (exceptionMesgStr + ".");
     			       throw new TransformerException("FODC0005 : A dynamic error has occured, evaluating XPath built-in "
-    			       		                                                              + "constructor function call. " + 
-    			    		                                                              ex.getMessage() + ".", srcLocator);
+    			       		                                                              + "constructor function call." + exceptionMesgStr, srcLocator);
     			    }
     			}
     			else {


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