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 2023/07/10 14:35:59 UTC

[xalan-java] branch xalan-j_xslt3.0 updated: improving a bit, the implementation of xpath 3.1 dynamic function calls. add a related new, working test case as well. doing minor improvements to comments, within few existing xslt 3.0 xalanj test cases.

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

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


The following commit(s) were added to refs/heads/xalan-j_xslt3.0 by this push:
     new a6d15311 improving a bit, the implementation of xpath 3.1 dynamic function calls. add a related new, working test case as well. doing minor improvements to comments, within few existing xslt 3.0 xalanj test cases.
     new d2ff9400 Merge pull request #24 from mukulga/xalan-j_xslt3.0_mukul
a6d15311 is described below

commit a6d15311ba3ec0efee9f3cdeab4ea97be9f062ff
Author: Mukul Gandhi <ga...@gmail.com>
AuthorDate: Mon Jul 10 19:59:45 2023 +0530

    improving a bit, the implementation of xpath 3.1 dynamic function calls. add a related new, working test case as well. doing minor improvements to comments, within few existing xslt 3.0 xalanj test cases.
---
 src/org/apache/xpath/XPathContext.java                     |  2 +-
 src/org/apache/xpath/operations/Variable.java              | 10 ++++++++--
 tests/dynamic_function_call/gold/test9.out                 | 14 ++++++++++++++
 tests/dynamic_function_call/test1.xsl                      |  2 +-
 tests/dynamic_function_call/test2.xsl                      |  2 +-
 tests/dynamic_function_call/test3.xsl                      |  2 +-
 tests/dynamic_function_call/test4.xsl                      |  2 +-
 tests/dynamic_function_call/test5.xsl                      |  2 +-
 tests/dynamic_function_call/test6.xsl                      |  2 +-
 tests/dynamic_function_call/test7.xsl                      |  2 +-
 tests/dynamic_function_call/{test6.xsl => test9.xsl}       |  8 +++++---
 .../org/apache/xalan/xpath3/DynamicFunctionCallTests.java  | 10 ++++++++++
 12 files changed, 45 insertions(+), 13 deletions(-)

diff --git a/src/org/apache/xpath/XPathContext.java b/src/org/apache/xpath/XPathContext.java
index 9fba1a4d..ef617fad 100644
--- a/src/org/apache/xpath/XPathContext.java
+++ b/src/org/apache/xpath/XPathContext.java
@@ -130,7 +130,7 @@ public class XPathContext extends DTMManager // implements ExpressionContext
   private XSDuration m_timezone;
   
   // we use this java.util.Map object, to store for XPath 3.1 function item 
-  // "inline function" the parameter names and their values. we don't use,
+  // "inline function", the parameter names and their values. we don't use,
   // XalanJ XPath context's variable stack for this purpose. 
   private Map<QName, XObject> inlineFunctionVarMap = new HashMap<QName, XObject>();
 	
diff --git a/src/org/apache/xpath/operations/Variable.java b/src/org/apache/xpath/operations/Variable.java
index 05a58138..eb8b1b47 100644
--- a/src/org/apache/xpath/operations/Variable.java
+++ b/src/org/apache/xpath/operations/Variable.java
@@ -214,8 +214,14 @@ public class Variable extends Expression implements PathComponent
     
     if (inlineFuncVarValue != null) {
         // dereferencing, XPath 3.1 function item "inline function" 
-        // parameter reference within "inline function" body. 
-        result = inlineFuncVarValue;
+        // parameter reference within "inline function" body.
+        if (inlineFuncVarValue instanceof XNodeSet) {
+           result = ((XNodeSet)inlineFuncVarValue).getFresh();    
+        }
+        else {
+           result = inlineFuncVarValue;
+        }
+        
         return result;
     }
     
diff --git a/tests/dynamic_function_call/gold/test9.out b/tests/dynamic_function_call/gold/test9.out
new file mode 100644
index 00000000..191f5e0c
--- /dev/null
+++ b/tests/dynamic_function_call/gold/test9.out
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?><result>
+  <item>
+     <a>5</a>
+     <b>2</b>
+   </item>
+  <item>
+     <a>3</a>
+     <b>1</b>
+   </item>
+  <item>
+     <a>7</a>
+     <b>4</b>
+   </item>
+</result>
diff --git a/tests/dynamic_function_call/test1.xsl b/tests/dynamic_function_call/test1.xsl
index 6334dd64..6f0c3fd7 100644
--- a/tests/dynamic_function_call/test1.xsl
+++ b/tests/dynamic_function_call/test1.xsl
@@ -5,7 +5,7 @@
    <!-- Author: mukulg@apache.org -->
    
    <!-- An XSLT stylesheet, to test the XPath 3.1 dynamic function 
-        calls. -->                
+        call. -->                
 
    <xsl:output method="xml" indent="yes"/>
    
diff --git a/tests/dynamic_function_call/test2.xsl b/tests/dynamic_function_call/test2.xsl
index 0d98ca77..2b4b1d0c 100644
--- a/tests/dynamic_function_call/test2.xsl
+++ b/tests/dynamic_function_call/test2.xsl
@@ -7,7 +7,7 @@
    <!-- use with test1_a.xml -->
    
    <!-- An XSLT stylesheet, to test the XPath 3.1 dynamic function 
-        calls. -->                
+        call. -->                
 
    <xsl:output method="xml" indent="yes"/>
    
diff --git a/tests/dynamic_function_call/test3.xsl b/tests/dynamic_function_call/test3.xsl
index 6e9b3fe8..98955410 100644
--- a/tests/dynamic_function_call/test3.xsl
+++ b/tests/dynamic_function_call/test3.xsl
@@ -7,7 +7,7 @@
    <!-- use with test1_a.xml -->
    
    <!-- An XSLT stylesheet, to test the XPath 3.1 dynamic function 
-        calls. -->                 
+        call. -->                 
 
    <xsl:output method="xml" indent="yes"/>
 
diff --git a/tests/dynamic_function_call/test4.xsl b/tests/dynamic_function_call/test4.xsl
index af258c07..b31ac4c8 100644
--- a/tests/dynamic_function_call/test4.xsl
+++ b/tests/dynamic_function_call/test4.xsl
@@ -7,7 +7,7 @@
    <!-- use with test1_a.xml -->
    
    <!-- An XSLT stylesheet, to test the XPath 3.1 dynamic function 
-        calls. -->                 
+        call. -->                 
 
    <xsl:output method="xml" indent="yes"/>
 
diff --git a/tests/dynamic_function_call/test5.xsl b/tests/dynamic_function_call/test5.xsl
index 9d3eaee7..44ef274e 100644
--- a/tests/dynamic_function_call/test5.xsl
+++ b/tests/dynamic_function_call/test5.xsl
@@ -7,7 +7,7 @@
    <!-- use with test1_b.xml -->
    
    <!-- An XSLT stylesheet, to test the XPath 3.1 dynamic function 
-        calls. -->                
+        call. -->                
 
    <xsl:output method="xml" indent="yes"/>
    
diff --git a/tests/dynamic_function_call/test6.xsl b/tests/dynamic_function_call/test6.xsl
index 63e601c0..5b0c9a04 100644
--- a/tests/dynamic_function_call/test6.xsl
+++ b/tests/dynamic_function_call/test6.xsl
@@ -7,7 +7,7 @@
    <!-- use with test1_c.xml -->
    
    <!-- An XSLT stylesheet, to test the XPath 3.1 dynamic function 
-        calls. -->                
+        call. -->                
 
    <xsl:output method="xml" indent="yes"/>
    
diff --git a/tests/dynamic_function_call/test7.xsl b/tests/dynamic_function_call/test7.xsl
index 6e9d1d2f..4c8251b2 100644
--- a/tests/dynamic_function_call/test7.xsl
+++ b/tests/dynamic_function_call/test7.xsl
@@ -7,7 +7,7 @@
    <!-- use with test1_c.xml -->
    
    <!-- An XSLT stylesheet, to test the XPath 3.1 dynamic function 
-        calls when used with xsl:for-each-group. -->                 
+        call when used with xsl:for-each-group. -->                 
 
    <xsl:output method="xml" indent="yes"/>
    
diff --git a/tests/dynamic_function_call/test6.xsl b/tests/dynamic_function_call/test9.xsl
similarity index 79%
copy from tests/dynamic_function_call/test6.xsl
copy to tests/dynamic_function_call/test9.xsl
index 63e601c0..4672f9e5 100644
--- a/tests/dynamic_function_call/test6.xsl
+++ b/tests/dynamic_function_call/test9.xsl
@@ -7,15 +7,17 @@
    <!-- use with test1_c.xml -->
    
    <!-- An XSLT stylesheet, to test the XPath 3.1 dynamic function 
-        calls. -->                
+        call. The argument passed with the dynamic function call within
+        this stylesheet example, is an XML element node with a sub 
+        structure.-->                
 
    <xsl:output method="xml" indent="yes"/>
    
-   <xsl:variable name="gThan" select="function($x, $y) { $x gt $y }"/>
+   <xsl:variable name="isItemOk" select="function($item) { $item/a gt $item/b }"/>
 
    <xsl:template match="/list">
       <result>
-         <xsl:copy-of select="item[$gThan(a, b)]"/> 
+         <xsl:copy-of select="item[$isItemOk(.)]"/> 
       </result>
    </xsl:template>
    
diff --git a/tests/org/apache/xalan/xpath3/DynamicFunctionCallTests.java b/tests/org/apache/xalan/xpath3/DynamicFunctionCallTests.java
index 3a12aa06..3785d0d6 100644
--- a/tests/org/apache/xalan/xpath3/DynamicFunctionCallTests.java
+++ b/tests/org/apache/xalan/xpath3/DynamicFunctionCallTests.java
@@ -126,5 +126,15 @@ public class DynamicFunctionCallTests extends XslTransformTestsUtil {
         
         runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
     }
+    
+    @Test
+    public void xslDynamicFunctionCallTest9() {
+        String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test1_c.xml"; 
+        String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test9.xsl";
+        
+        String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test9.out";                
+        
+        runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+    }
 
 }


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