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/10/04 15:50:06 UTC

(xalan-java) branch xalan-j_xslt3.0_mvn updated: committing few xsl styleheet test cases for xslt 3.0's xsl:iterate instruction

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 3e5894350 committing few xsl styleheet test cases for xslt 3.0's xsl:iterate instruction
3e5894350 is described below

commit 3e58943505c72eaea876c0ebdae2a6e46fde0a4d
Author: Mukul Gandhi <ga...@gmail.com>
AuthorDate: Sat Oct 4 21:19:39 2025 +0530

    committing few xsl styleheet test cases for xslt 3.0's xsl:iterate instruction
---
 README                                             |  8 +--
 .../apache/xalan/tests/xslt3/XslIterateTests.java  | 20 +++++++
 .../xsl_iterate/gold/iterate_fn_index_of.out       |  4 ++
 .../resources/xsl_iterate/iterate_fn_index_of1.xsl | 69 ++++++++++++++++++++++
 .../resources/xsl_iterate/iterate_fn_index_of2.xsl | 60 +++++++++++++++++++
 5 files changed, 157 insertions(+), 4 deletions(-)

diff --git a/README b/README
index 1b8ee2bf8..8a6e25d59 100644
--- a/README
+++ b/README
@@ -17,7 +17,7 @@
 
 Copyright 1999-2025 The Apache Software Foundation
 
-Document last modified : 2025-09-29
+Document last modified : 2025-10-04
 
 Authors:
    Gary Gregory <gg...@apache.org>
@@ -49,11 +49,11 @@ The Maven build results like following shall be produced:
 [INFO]  T E S T S
 [INFO] -------------------------------------------------------
 [INFO] Running org.apache.xalan.tests.main.AllXalanXSLT3Tests
-[INFO] Tests run: 1313, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 62.342 s - in org.apache.xalan.tests.main.AllXalanXSLT3Tests
+[INFO] Tests run: 1315, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: ..... - in org.apache.xalan.tests.main.AllXalanXSLT3Tests
 [INFO]
 [INFO] Results:
 [INFO]
-[INFO] Tests run: 1313, Failures: 0, Errors: 0, Skipped: 0
+[INFO] Tests run: 1315, Failures: 0, Errors: 0, Skipped: 0
 [INFO]
 [INFO]
 [INFO] --- jar:3.3.0:jar (default-jar) @ xalan-java ---
@@ -62,7 +62,7 @@ The Maven build results like following shall be produced:
 [INFO] ------------------------------------------------------------------------
 [INFO] BUILD SUCCESS
 [INFO] ------------------------------------------------------------------------
-[INFO] Total time:  03:10 min
+[INFO] Total time:  .....
 
 
 If the user needs to run Xalan-J's XSLT 3.0 implementation via Java application code, the value of JVM's system property 
diff --git a/src/test/java/org/apache/xalan/tests/xslt3/XslIterateTests.java b/src/test/java/org/apache/xalan/tests/xslt3/XslIterateTests.java
index 124527c64..11f90fca2 100644
--- a/src/test/java/org/apache/xalan/tests/xslt3/XslIterateTests.java
+++ b/src/test/java/org/apache/xalan/tests/xslt3/XslIterateTests.java
@@ -371,5 +371,25 @@ public class XslIterateTests extends XslTransformTestsUtil {
         
         runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
     }
+    
+    @Test
+    public void xslIterateTestIndexOf1() {
+    	String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "iterate_fn_index_of1.xsl"; 
+        String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "iterate_fn_index_of1.xsl";
+        
+        String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "iterate_fn_index_of.out";              
+        
+        runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+    }
+    
+    @Test
+    public void xslIterateTestIndexOf2() {
+    	String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "iterate_fn_index_of2.xsl"; 
+        String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "iterate_fn_index_of2.xsl";
+        
+        String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "iterate_fn_index_of.out";              
+        
+        runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+    }
 
 }
diff --git a/src/test/resources/xsl_iterate/gold/iterate_fn_index_of.out b/src/test/resources/xsl_iterate/gold/iterate_fn_index_of.out
new file mode 100644
index 000000000..50038cda4
--- /dev/null
+++ b/src/test/resources/xsl_iterate/gold/iterate_fn_index_of.out
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?><result>
+  <index srch="abc1">1 3</index>
+  <index srch="abc4">5</index>
+</result>
diff --git a/src/test/resources/xsl_iterate/iterate_fn_index_of1.xsl b/src/test/resources/xsl_iterate/iterate_fn_index_of1.xsl
new file mode 100644
index 000000000..dde30169f
--- /dev/null
+++ b/src/test/resources/xsl_iterate/iterate_fn_index_of1.xsl
@@ -0,0 +1,69 @@
+<?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:fn0="http://fn0"
+                exclude-result-prefixes="#all"				
+                version="3.0">
+                
+    <!-- Author: mukulg@apache.org -->
+    
+    <!-- An XSL stylesheet test case, to test implementation similar 
+         to that of XPath 3.1 function fn:index-of using XSLT 3.0's 
+         xsl:iterate instruction. -->                			
+				
+    <xsl:output method="xml" indent="yes"/>
+
+	<xsl:variable name="var1">
+	   <words>
+		  <str>abc1</str>
+	      <str>abc2</str>
+	      <str>abc1</str>
+	      <str>abc5</str>
+	      <str>abc4</str>
+	   </words>
+	</xsl:variable>
+				
+	<xsl:template match="/">
+		<result>
+		   <xsl:variable name="strList" select="for $str1 in $var1/words/str return xs:string($str1)"/>
+		   <xsl:for-each select="('abc1', 'abc4')">
+		     <index srch="{.}"><xsl:value-of select="fn0:index-of($strList, .)"/></index>
+		   </xsl:for-each>
+		</result>
+	</xsl:template>
+	
+	<xsl:function name="fn0:index-of" as="xs:integer*">
+	   <xsl:param name="strList" as="xs:string*"/>
+	   <xsl:param name="srch1" as="xs:string"/>
+	   <xsl:iterate select="$strList">
+	      <xsl:param name="result" select="()" as="xs:integer*"/>
+		  <xsl:on-completion>
+		     <xsl:sequence select="$result"/>
+		  </xsl:on-completion>
+		  <xsl:if test=". eq $srch1">
+		     <xsl:next-iteration>
+			   <xsl:with-param name="result" select="($result, position())"/>
+			 </xsl:next-iteration>
+		  </xsl:if>
+	   </xsl:iterate>
+	</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>
diff --git a/src/test/resources/xsl_iterate/iterate_fn_index_of2.xsl b/src/test/resources/xsl_iterate/iterate_fn_index_of2.xsl
new file mode 100644
index 000000000..1bfcff3a3
--- /dev/null
+++ b/src/test/resources/xsl_iterate/iterate_fn_index_of2.xsl
@@ -0,0 +1,60 @@
+<?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:fn0="http://fn0"
+                exclude-result-prefixes="#all"				
+                version="3.0">
+                
+    <!-- Author: mukulg@apache.org -->
+    
+    <!-- An XSL stylesheet test case, to test implementation similar 
+         to that of XPath 3.1 function fn:index-of using XSLT 3.0's 
+         xsl:iterate instruction. -->                 			
+				
+    <xsl:output method="xml" indent="yes"/>
+
+	<xsl:variable name="strList1" select="('abc1', 'abc2', 'abc1', 'abc5', 'abc4')" as="xs:string*"/>
+				
+	<xsl:template match="/">
+		<result>
+		   <xsl:for-each select="('abc1', 'abc4')">
+		     <index srch="{.}"><xsl:value-of select="fn0:index-of($strList1, .)"/></index>
+		   </xsl:for-each>
+		</result>
+	</xsl:template>
+	
+	<xsl:function name="fn0:index-of" as="xs:integer*">
+	   <xsl:param name="strList" as="xs:string*"/>
+	   <xsl:param name="srch1" as="xs:string"/>
+	   <xsl:iterate select="$strList">
+	      <xsl:param name="result" select="()" as="xs:integer*"/>
+		  <xsl:on-completion>
+		     <xsl:sequence select="$result"/>
+		  </xsl:on-completion>
+		  <xsl:if test=". eq $srch1">
+		     <xsl:next-iteration>
+			   <xsl:with-param name="result" select="($result, position())"/>
+			 </xsl:next-iteration>
+		  </xsl:if>
+	   </xsl:iterate>
+	</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>


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