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/10/14 14:43:33 UTC

[xalan-java] branch xalan-j_xslt3.0 updated: committing a bug fix, for xslt 3.0 xsl:function element implementation, and few new related working test cases as well. also doing minor test suite refactoring as well, on this xalanj dev repos branch.

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 f46661d6 committing a bug fix, for xslt 3.0 xsl:function element implementation, and few new related working test cases as well. also doing minor test suite refactoring as well, on this xalanj dev repos branch.
     new e52ae0f9 Merge pull request #100 from mukulga/xalan-j_xslt3.0_mukul
f46661d6 is described below

commit f46661d6dde7c04ed41961a5ca863699198910b6
Author: Mukul Gandhi <ga...@gmail.com>
AuthorDate: Sat Oct 14 20:08:42 2023 +0530

    committing a bug fix, for xslt 3.0 xsl:function element implementation, and few new related working test cases as well. also doing minor test suite refactoring as well, on this xalanj dev repos branch.
---
 src/org/apache/xalan/templates/ElemFunction.java   |  3 +-
 tests/org/apache/xalan/xslt3/Xsl3TestSuite1.java   |  2 +-
 tests/org/apache/xalan/xslt3/Xsl3TestSuite2.java   |  2 +-
 tests/org/apache/xalan/xslt3/XslFunctionTests.java | 22 +++++++-
 tests/xsl_function/gold/test16.out                 | 14 +++++
 tests/xsl_function/gold/test17.out                 |  6 +++
 tests/xsl_function/test16.xsl                      | 60 +++++++++++++++++++++
 tests/xsl_function/test17.xsl                      | 61 ++++++++++++++++++++++
 8 files changed, 165 insertions(+), 5 deletions(-)

diff --git a/src/org/apache/xalan/templates/ElemFunction.java b/src/org/apache/xalan/templates/ElemFunction.java
index 5881a4dd..d27b309b 100644
--- a/src/org/apache/xalan/templates/ElemFunction.java
+++ b/src/org/apache/xalan/templates/ElemFunction.java
@@ -281,8 +281,7 @@ public class ElemFunction extends ElemTemplate
       
       if (funcResultConvertedVal instanceof ResultSequence) {
          ResultSequence resultSeq = (ResultSequence)funcResultConvertedVal;
-         int resultSeqSize = resultSeq.size();
-         if ((resultSeqSize == 1) && (resultSeq.item(0) instanceof XNodeSet)) {
+         if (resultSeq.size() == 1) {
             funcResultConvertedVal = resultSeq.item(0);   
          }
       }
diff --git a/tests/org/apache/xalan/xslt3/Xsl3TestSuite1.java b/tests/org/apache/xalan/xslt3/Xsl3TestSuite1.java
index 2bcab3c6..8890efcb 100644
--- a/tests/org/apache/xalan/xslt3/Xsl3TestSuite1.java
+++ b/tests/org/apache/xalan/xslt3/Xsl3TestSuite1.java
@@ -31,7 +31,7 @@ import org.junit.runners.Suite.SuiteClasses;
  */
 @RunWith(Suite.class)
 @SuiteClasses({ FnDocTests.class, FnDataTests.class, RecursiveFunctionTests.class,
-                HigherOrderFunctionTests.class })
+                XslFunctionTests.class, HigherOrderFunctionTests.class })
 public class Xsl3TestSuite1 {
 
 }
diff --git a/tests/org/apache/xalan/xslt3/Xsl3TestSuite2.java b/tests/org/apache/xalan/xslt3/Xsl3TestSuite2.java
index 214302b3..2c586496 100644
--- a/tests/org/apache/xalan/xslt3/Xsl3TestSuite2.java
+++ b/tests/org/apache/xalan/xslt3/Xsl3TestSuite2.java
@@ -90,7 +90,7 @@ import org.junit.runners.Suite.SuiteClasses;
                 SequenceFunctionTests.class, FnParseXmlTests.class, FnParseXmlFragmentTests.class,
                 TemplateTests.class, FnAvgTests.class, FnMaxTests.class, FnMinTests.class, FnContainsTokenTests.class,
                 XslVariableAttributeAsTests.class, InstanceOfExprTests.class, XslTemplateAttributeAsTests.class,
-                XslFunctionTests.class, FnRoundTests.class, XslSequenceInstTests.class })
+                FnRoundTests.class, XslSequenceInstTests.class })
 public class Xsl3TestSuite2 {
 
 }
diff --git a/tests/org/apache/xalan/xslt3/XslFunctionTests.java b/tests/org/apache/xalan/xslt3/XslFunctionTests.java
index c6d6bfdc..2e9efc9b 100644
--- a/tests/org/apache/xalan/xslt3/XslFunctionTests.java
+++ b/tests/org/apache/xalan/xslt3/XslFunctionTests.java
@@ -23,7 +23,7 @@ import org.junit.Test;
 
 /**
  * XSLT test cases, to test stylesheet functions defined 
- * with syntax xsl:function.
+ * with xsl:function syntax.
  * 
  * @author Mukul Gandhi <mu...@apache.org>
  * 
@@ -197,5 +197,25 @@ public class XslFunctionTests extends XslTransformTestsUtil {
         
         runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
     }
+    
+    @Test
+    public void xslFunctionTest16() {
+        String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test16.xsl"; 
+        String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test16.xsl";
+        
+        String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test16.out";                
+        
+        runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+    }
+    
+    @Test
+    public void xslFunctionTest17() {
+        String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test17.xsl"; 
+        String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test17.xsl";
+        
+        String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test17.out";                
+        
+        runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+    }
 
 }
diff --git a/tests/xsl_function/gold/test16.out b/tests/xsl_function/gold/test16.out
new file mode 100644
index 00000000..a79c3da6
--- /dev/null
+++ b/tests/xsl_function/gold/test16.out
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?><result>
+  <andTest>
+    <one>false</one>
+    <two>false</two>
+    <three>false</three>
+    <four>true</four>
+  </andTest>
+  <orTest>
+    <one>false</one>
+    <two>true</two>
+    <three>true</three>
+    <four>true</four>
+  </orTest>
+</result>
diff --git a/tests/xsl_function/gold/test17.out b/tests/xsl_function/gold/test17.out
new file mode 100644
index 00000000..ca68fbeb
--- /dev/null
+++ b/tests/xsl_function/gold/test17.out
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?><result>
+  <plusTest>7</plusTest>
+  <minusTest>4</minusTest>
+  <sqrt1>2.6457513110645907</sqrt1>
+  <sqrt2>2</sqrt2>
+</result>
diff --git a/tests/xsl_function/test16.xsl b/tests/xsl_function/test16.xsl
new file mode 100644
index 00000000..1b4426dc
--- /dev/null
+++ b/tests/xsl_function/test16.xsl
@@ -0,0 +1,60 @@
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                xmlns:xs="http://www.w3.org/2001/XMLSchema"
+                xmlns:fn0="http://fn0"
+                exclude-result-prefixes="xs fn0"
+                version="3.0">
+                
+  <!-- Author: mukulg@apache.org -->
+  
+  <!-- An XSLT stylesheet test case, that tests XPath boolean binary 
+       operators 'and' and 'or', when the operands to these XPath 
+       operators are stylesheet function calls. 
+  -->                
+                
+  <xsl:output method="xml" indent="yes"/>
+  
+  <xsl:template match="/">     
+     <result>
+        <andTest>
+           <one><xsl:value-of select="fn0:isInteger('abc') and fn0:isInteger('pqr')"/></one>
+           <two><xsl:value-of select="fn0:isInteger('abc') and fn0:isInteger(5)"/></two>
+           <three><xsl:value-of select="fn0:isInteger(5) and fn0:isInteger('abc')"/></three>
+           <four><xsl:value-of select="fn0:isInteger(7) and fn0:isInteger(5)"/></four>
+        </andTest>
+        <orTest>
+           <one><xsl:value-of select="fn0:isInteger('abc') or fn0:isInteger('pqr')"/></one>
+           <two><xsl:value-of select="fn0:isInteger('abc') or fn0:isInteger(5)"/></two>
+           <three><xsl:value-of select="fn0:isInteger(5) or fn0:isInteger('abc')"/></three>
+           <four><xsl:value-of select="fn0:isInteger(7) or fn0:isInteger(5)"/></four>
+        </orTest>
+     </result>
+  </xsl:template>
+  
+  <!-- A stylesheet function that checks whether, an argument value
+       passed to this function is of type xs:integer.
+  -->
+  <xsl:function name="fn0:isInteger" as="xs:boolean">
+    <xsl:param name="a" as="item()"/>
+    
+    <xsl:sequence select="$a instance of xs:integer"/>
+  </xsl:function>
+  
+  <!--
+      * 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>
\ No newline at end of file
diff --git a/tests/xsl_function/test17.xsl b/tests/xsl_function/test17.xsl
new file mode 100644
index 00000000..43e4242c
--- /dev/null
+++ b/tests/xsl_function/test17.xsl
@@ -0,0 +1,61 @@
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                xmlns:xs="http://www.w3.org/2001/XMLSchema"
+                xmlns:math="http://www.w3.org/2005/xpath-functions/math"
+                xmlns:fn0="http://fn0"
+                exclude-result-prefixes="xs math fn0"
+                version="3.0">
+                
+  <!-- Author: mukulg@apache.org -->
+  
+ <!-- An XSLT stylesheet test case, that tests XPath arithmetic binary 
+      operators '+' and '-', when the operands to these XPath operators 
+      are stylesheet function calls. 
+  -->                
+                
+  <xsl:output method="xml" indent="yes"/>
+  
+  <xsl:template match="/">     
+     <result>
+        <plusTest>
+           <xsl:value-of select="fn0:echoArg(2) + fn0:echoArg(5)"/>
+        </plusTest>
+        <minusTest>
+           <xsl:value-of select="fn0:echoArg(7) - fn0:echoArg(3)"/>
+        </minusTest>
+        <sqrt1>
+           <xsl:value-of select="math:sqrt(fn0:echoArg(2) + fn0:echoArg(5))"/>
+        </sqrt1>
+        <sqrt2>
+           <xsl:value-of select="math:sqrt(fn0:echoArg(7) - fn0:echoArg(3))"/>
+        </sqrt2>
+     </result>
+  </xsl:template>
+  
+  <!-- A stylesheet function, that returns a xs:double value, which is
+       equal to the value passed to this function as an argument.
+  -->
+  <xsl:function name="fn0:echoArg" as="xs:double">
+    <xsl:param name="a" as="xs:double"/>
+    
+    <xsl:sequence select="$a"/>
+  </xsl:function>
+  
+  <!--
+      * 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>
\ No newline at end of file


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