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/08/25 14:17:19 UTC

[xalan-java] branch xalan-j_xslt3.0 updated: adding few new working test cases for, xpath 3.1 'if' expression

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 b0f1309d adding few new working test cases for, xpath 3.1 'if' expression
     new e5ae3dac Merge pull request #62 from mukulga/xalan-j_xslt3.0_mukul
b0f1309d is described below

commit b0f1309da297df3870d54f756099890e0a3cf7b9
Author: Mukul Gandhi <ga...@gmail.com>
AuthorDate: Fri Aug 25 19:42:56 2023 +0530

    adding few new working test cases for, xpath 3.1 'if' expression
---
 tests/if_expr/gold/test12.out                  |  4 ++
 tests/if_expr/gold/test13.out                  | 14 +++++++
 tests/if_expr/test11.xsl                       | 51 +++++++++++++++++++++++
 tests/if_expr/test12.xsl                       | 56 ++++++++++++++++++++++++++
 tests/org/apache/xalan/xpath3/IfExprTests.java | 20 +++++++++
 5 files changed, 145 insertions(+)

diff --git a/tests/if_expr/gold/test12.out b/tests/if_expr/gold/test12.out
new file mode 100644
index 00000000..e8b32ce5
--- /dev/null
+++ b/tests/if_expr/gold/test12.out
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?><result>
+  <one>MIKE</one>
+  <two>mike</two>
+</result>
diff --git a/tests/if_expr/gold/test13.out b/tests/if_expr/gold/test13.out
new file mode 100644
index 00000000..f4627e2b
--- /dev/null
+++ b/tests/if_expr/gold/test13.out
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?><result>
+  <data>
+    <one>MIKE</one>
+    <two>mike</two>
+  </data>
+  <data>
+    <one>JOSEPH</one>
+    <two>joseph</two>
+  </data>
+  <data>
+    <one>GARY</one>
+    <two>gary</two>
+  </data>
+</result>
diff --git a/tests/if_expr/test11.xsl b/tests/if_expr/test11.xsl
new file mode 100644
index 00000000..671cf272
--- /dev/null
+++ b/tests/if_expr/test11.xsl
@@ -0,0 +1,51 @@
+<?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 the XPath 3.1 
+         "if" expression.
+         
+         The XPath "if" expressions used within this stylesheet,
+         are conceptually borrowed from W3C XSLT 3.0 test 
+         suite. -->                 
+                
+    <xsl:output method="xml" indent="yes"/>                
+                
+    <xsl:variable name="nameVal" select="'Mike'"/>                
+        
+    <xsl:template match="/">
+       <result>
+          <one>
+             <xsl:value-of select="if (current-date() gt xs:date('2000-12-31')) 
+                                             then upper-case($nameVal) else lower-case($nameVal)"/>
+          </one>
+          <two>
+	         <xsl:value-of select="if (current-date() gt xs:date('2501-12-31')) 
+	                                         then upper-case($nameVal) else lower-case($nameVal)"/>
+          </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/if_expr/test12.xsl b/tests/if_expr/test12.xsl
new file mode 100644
index 00000000..eb633868
--- /dev/null
+++ b/tests/if_expr/test12.xsl
@@ -0,0 +1,56 @@
+<?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 the XPath 3.1 
+         "if" expression.
+         
+         The XPath "if" expressions used within this stylesheet,
+         are conceptually borrowed from W3C XSLT 3.0 test 
+         suite. -->                 
+                
+    <xsl:output method="xml" indent="yes"/>                
+                
+    <xsl:variable name="nameValSeq" select="('Mike', 'Joseph', 'Gary')"/>                
+        
+    <xsl:template match="/">
+       <result>
+          <xsl:for-each select="$nameValSeq">
+             <xsl:variable name="currentItem" select="."/>
+             <data>
+                <one>
+                   <xsl:value-of select="if (current-date() gt xs:date('2000-12-31')) 
+                                                       then upper-case($currentItem) else lower-case($currentItem)"/>
+                </one>
+                <two>
+	           <xsl:value-of select="if (current-date() gt xs:date('2501-12-31')) 
+	                                               then upper-case($currentItem) else lower-case($currentItem)"/>
+                </two>
+             </data>
+          </xsl:for-each>
+       </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/IfExprTests.java b/tests/org/apache/xalan/xpath3/IfExprTests.java
index 658cbb09..75c527db 100644
--- a/tests/org/apache/xalan/xpath3/IfExprTests.java
+++ b/tests/org/apache/xalan/xpath3/IfExprTests.java
@@ -156,5 +156,25 @@ public class IfExprTests extends XslTransformTestsUtil {
         
         runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
     }
+    
+    @Test
+    public void xslIfExprTest12() {
+        String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test11.xsl"; 
+        String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test11.xsl";
+        
+        String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test12.out";                
+        
+        runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+    }
+    
+    @Test
+    public void xslIfExprTest13() {
+        String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test12.xsl"; 
+        String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test12.xsl";
+        
+        String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test13.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