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/09/20 16:56:26 UTC

[xalan-java] branch xalan-j_xslt3.0 updated: committing minor improvement to xpath 3.1's implementation of xs:boolean data type, that solves few implementation issues with xpath 3.1 inline function expression and xslt 3.0 xsl:function implementation

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 350f430a committing minor improvement to xpath 3.1's implementation of xs:boolean data type, that solves few implementation issues with xpath 3.1 inline function expression and xslt 3.0 xsl:function implementation
     new db09330b Merge pull request #88 from mukulga/xalan-j_xslt3.0_mukul
350f430a is described below

commit 350f430a6741f7bdf93d5fed4e0c1f906f5a2154
Author: Mukul Gandhi <ga...@gmail.com>
AuthorDate: Wed Sep 20 22:11:22 2023 +0530

    committing minor improvement to xpath 3.1's implementation of xs:boolean data type, that solves few implementation issues with xpath 3.1 inline function expression and xslt 3.0 xsl:function implementation
---
 src/org/apache/xpath/xs/types/XSBoolean.java       |  8 ++--
 tests/dynamic_function_call/gold/test18.out        |  4 ++
 tests/dynamic_function_call/test17.xsl             | 49 ++++++++++++++++++++
 tests/dynamic_function_call/test18.xsl             | 49 ++++++++++++++++++++
 .../xalan/xpath3/DynamicFunctionCallTests.java     | 20 ++++++++
 tests/org/apache/xalan/xslt3/XslFunctionTests.java | 20 ++++++++
 tests/xsl_function/test8.xsl                       | 54 ++++++++++++++++++++++
 tests/xsl_function/test9.xsl                       | 54 ++++++++++++++++++++++
 8 files changed, 254 insertions(+), 4 deletions(-)

diff --git a/src/org/apache/xpath/xs/types/XSBoolean.java b/src/org/apache/xpath/xs/types/XSBoolean.java
index 4dfcbd85..49780218 100644
--- a/src/org/apache/xpath/xs/types/XSBoolean.java
+++ b/src/org/apache/xpath/xs/types/XSBoolean.java
@@ -21,10 +21,6 @@ import org.apache.xpath.objects.ResultSequence;
 /**
  * An XML Schema data type representation, of the xs:boolean datatype.
  * 
- * We've this data type implementation, equivalent to XalanJ's legacy 
- * data type implementation org.apache.xpath.objects.XBoolean for boolean 
- * values. We may use, both of these classes for XalanJ's needs.
- * 
  * @author Mukul Gandhi <mu...@apache.org>
  * 
  * @xsl.usage advanced
@@ -123,6 +119,10 @@ public class XSBoolean extends XSCtrType {
         return resultVal;  
     }
     
+    public boolean bool() {
+        return value();  
+    }
+    
     public int getType() {
         return CLASS_BOOLEAN;
     }
diff --git a/tests/dynamic_function_call/gold/test18.out b/tests/dynamic_function_call/gold/test18.out
new file mode 100644
index 00000000..33530963
--- /dev/null
+++ b/tests/dynamic_function_call/gold/test18.out
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?><result>
+  <one>false</one>
+  <two>true</two>
+</result>
diff --git a/tests/dynamic_function_call/test17.xsl b/tests/dynamic_function_call/test17.xsl
new file mode 100644
index 00000000..e6c79ab0
--- /dev/null
+++ b/tests/dynamic_function_call/test17.xsl
@@ -0,0 +1,49 @@
+<?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"
+                exclude-result-prefixes="xs"
+                version="3.0">
+                
+    <!-- Author: mukulg@apache.org -->
+    
+    <!-- An XSLT stylesheet test case, to test XPath 3.1
+         inline function expression and calling it via
+         dynamic function call.
+     -->                
+    
+    <xsl:output method="xml" indent="yes"/>
+    
+    <xsl:variable name="func1" select="function($val1 as xs:integer, $val2 as xs:integer, 
+                                                                 $a as xs:boolean, $b as xs:boolean) as xs:boolean 
+                                                                 { if ($val1 gt $val2) then ($a and $b) else ($a or $b) }"/>
+    
+    <xsl:template match="/">       
+       <result>
+          <one>
+             <xsl:value-of select="$func1(6, 5, xs:boolean('true'), xs:boolean('false'))"/>
+          </one>
+          <two>
+	         <xsl:value-of select="$func1(2, 5, xs:boolean('true'), xs:boolean('false'))"/>
+          </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>
\ No newline at end of file
diff --git a/tests/dynamic_function_call/test18.xsl b/tests/dynamic_function_call/test18.xsl
new file mode 100644
index 00000000..dde91d84
--- /dev/null
+++ b/tests/dynamic_function_call/test18.xsl
@@ -0,0 +1,49 @@
+<?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"
+                exclude-result-prefixes="xs"
+                version="3.0">
+                
+    <!-- Author: mukulg@apache.org -->
+    
+    <!-- An XSLT stylesheet test case, to test XPath 3.1
+         inline function expression and calling it via
+         dynamic function call.
+     -->                
+    
+    <xsl:output method="xml" indent="yes"/>
+    
+    <xsl:variable name="func1" select="function($val1 as xs:integer, $val2 as xs:integer, 
+                                                                 $a as xs:boolean, $b as xs:boolean) as xs:boolean 
+                                                                 { if ($val1 gt $val2) then ($a and $b) else ($a or $b) }"/>
+    
+    <xsl:template match="/">       
+       <result>
+          <one>
+             <xsl:value-of select="$func1(6, 5, true(), false())"/>
+          </one>
+          <two>
+	         <xsl:value-of select="$func1(2, 5, true(), false())"/>
+          </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>
\ No newline at end of file
diff --git a/tests/org/apache/xalan/xpath3/DynamicFunctionCallTests.java b/tests/org/apache/xalan/xpath3/DynamicFunctionCallTests.java
index 85f24f7b..ee40c5e9 100644
--- a/tests/org/apache/xalan/xpath3/DynamicFunctionCallTests.java
+++ b/tests/org/apache/xalan/xpath3/DynamicFunctionCallTests.java
@@ -206,5 +206,25 @@ public class DynamicFunctionCallTests extends XslTransformTestsUtil {
         
         runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
     }
+    
+    @Test
+    public void xslDynamicFunctionCallTest17() {
+        String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test17.xsl"; 
+        String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test17.xsl";
+        
+        String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test18.out";                
+        
+        runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+    }
+    
+    @Test
+    public void xslDynamicFunctionCallTest18() {
+        String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test18.xsl"; 
+        String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test18.xsl";
+        
+        String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test18.out";                
+        
+        runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+    }
 
 }
diff --git a/tests/org/apache/xalan/xslt3/XslFunctionTests.java b/tests/org/apache/xalan/xslt3/XslFunctionTests.java
index 2be36887..96d92cd6 100644
--- a/tests/org/apache/xalan/xslt3/XslFunctionTests.java
+++ b/tests/org/apache/xalan/xslt3/XslFunctionTests.java
@@ -117,5 +117,25 @@ public class XslFunctionTests extends XslTransformTestsUtil {
         
         runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
     }
+    
+    @Test
+    public void xslFunctionTest8() {
+        String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test8.xsl"; 
+        String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test8.xsl";
+        
+        String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test7.out";                
+        
+        runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+    }
+    
+    @Test
+    public void xslFunctionTest9() {
+        String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test9.xsl"; 
+        String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test9.xsl";
+        
+        String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test7.out";                
+        
+        runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+    }
 
 }
diff --git a/tests/xsl_function/test8.xsl b/tests/xsl_function/test8.xsl
new file mode 100644
index 00000000..11ca9b52
--- /dev/null
+++ b/tests/xsl_function/test8.xsl
@@ -0,0 +1,54 @@
+<?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:ns0="http://ns0"
+                exclude-result-prefixes="xs ns0"
+                version="3.0">
+                
+    <!-- Author: mukulg@apache.org -->
+    
+    <!-- An XSLT stylesheet test case, to test a stylesheet
+         function defined with an XSL element xsl:function.
+    -->                 
+    
+    <xsl:output method="xml" indent="yes"/>
+    
+    <xsl:template match="/">       
+       <result>
+          <one>
+             <xsl:value-of select="ns0:func1(6, 5, xs:boolean('true'), xs:boolean('false'))"/>
+          </one>
+          <two>
+	         <xsl:value-of select="ns0:func1(2, 5, xs:boolean('true'), xs:boolean('false'))"/>
+          </two>
+       </result>
+    </xsl:template>
+    
+    <xsl:function name="ns0:func1" as="xs:boolean">
+       <xsl:param name="val1" as="xs:integer"/>
+       <xsl:param name="val2" as="xs:integer"/>
+       <xsl:param name="a" as="xs:boolean"/>
+       <xsl:param name="b" as="xs:boolean"/>
+       
+       <xsl:value-of select="if ($val1 gt $val2) then ($a and $b) else ($a or $b)"/>
+    </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/test9.xsl b/tests/xsl_function/test9.xsl
new file mode 100644
index 00000000..962d3882
--- /dev/null
+++ b/tests/xsl_function/test9.xsl
@@ -0,0 +1,54 @@
+<?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:ns0="http://ns0"
+                exclude-result-prefixes="xs ns0"
+                version="3.0">
+                
+    <!-- Author: mukulg@apache.org -->
+    
+    <!-- An XSLT stylesheet test case, to test a stylesheet
+         function defined with an XSL element xsl:function.
+    -->                 
+    
+    <xsl:output method="xml" indent="yes"/>
+    
+    <xsl:template match="/">       
+       <result>
+          <one>
+             <xsl:value-of select="ns0:func1(6, 5, true(), false())"/>
+          </one>
+          <two>
+	         <xsl:value-of select="ns0:func1(2, 5, true(), false())"/>
+          </two>
+       </result>
+    </xsl:template>
+    
+    <xsl:function name="ns0:func1" as="xs:boolean">
+       <xsl:param name="val1" as="xs:integer"/>
+       <xsl:param name="val2" as="xs:integer"/>
+       <xsl:param name="a" as="xs:boolean"/>
+       <xsl:param name="b" as="xs:boolean"/>
+       
+       <xsl:value-of select="if ($val1 gt $val2) then ($a and $b) else ($a or $b)"/>
+    </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