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 2026/02/20 01:03:27 UTC
(xalan-java) branch xalan-j_xslt3.0_mvn updated: committing an xsl 3 stylesheet test case to test 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 029602230 committing an xsl 3 stylesheet test case to test xsl:iterate instruction
029602230 is described below
commit 02960223053a5f63379d2029f245c7d151085a9e
Author: Mukul Gandhi <ga...@gmail.com>
AuthorDate: Fri Feb 20 06:33:01 2026 +0530
committing an xsl 3 stylesheet test case to test xsl:iterate instruction
---
README | 6 +-
.../apache/xalan/tests/xslt3/XslIterateTests.java | 10 ++++
src/test/resources/xsl_iterate/gold/test31.out | 1 +
src/test/resources/xsl_iterate/test31.xsl | 67 ++++++++++++++++++++++
4 files changed, 81 insertions(+), 3 deletions(-)
diff --git a/README b/README
index 4e8b7fc7c..b39ed2e3c 100644
--- a/README
+++ b/README
@@ -17,7 +17,7 @@
Copyright 1999-2025 The Apache Software Foundation
-Document last modified : 2026-02-17
+Document last modified : 2026-02-20
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: 1399, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: ..... - in org.apache.xalan.tests.main.AllXalanXSLT3Tests
+[INFO] Tests run: 1400, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: ..... - in org.apache.xalan.tests.main.AllXalanXSLT3Tests
[INFO]
[INFO] Results:
[INFO]
-[INFO] Tests run: 1399, Failures: 0, Errors: 0, Skipped: 0
+[INFO] Tests run: 1400, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO]
[INFO] --- jar:3.3.0:jar (default-jar) @ xalan-java ---
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 11f90fca2..d80c3ec4f 100644
--- a/src/test/java/org/apache/xalan/tests/xslt3/XslIterateTests.java
+++ b/src/test/java/org/apache/xalan/tests/xslt3/XslIterateTests.java
@@ -391,5 +391,15 @@ public class XslIterateTests extends XslTransformTestsUtil {
runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
}
+
+ @Test
+ public void xslIterateTest33() {
+ String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test31.xsl";
+ String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test31.xsl";
+
+ String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test31.out";
+
+ runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+ }
}
diff --git a/src/test/resources/xsl_iterate/gold/test31.out b/src/test/resources/xsl_iterate/gold/test31.out
new file mode 100644
index 000000000..d3e381e59
--- /dev/null
+++ b/src/test/resources/xsl_iterate/gold/test31.out
@@ -0,0 +1 @@
+<?xml version="1.0" encoding="UTF-8"?><result>2.71828</result>
diff --git a/src/test/resources/xsl_iterate/test31.xsl b/src/test/resources/xsl_iterate/test31.xsl
new file mode 100644
index 000000000..5f5f7e927
--- /dev/null
+++ b/src/test/resources/xsl_iterate/test31.xsl
@@ -0,0 +1,67 @@
+<?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 XSLT 3.0 stylesheet example, to find Euler number's
+ numeric value. This stylesheet uses, xsl:iterate instruction,
+ to perform this activity.
+
+ Ref, https://en.wikipedia.org/wiki/E_(mathematical_constant)
+ -->
+
+ <!-- Number of iterations to carry -->
+ <xsl:variable name="limit" select="50" as="xs:integer"/>
+
+ <xsl:output method="xml" indent="yes"/>
+
+ <xsl:template match="/">
+ <result>
+ <xsl:value-of select="round(fn0:eulerNumber(),5)"/>
+ </result>
+ </xsl:template>
+
+ <!-- An XSL stylesheet function, to find Euler number's
+ numeric value. -->
+ <xsl:function name="fn0:eulerNumber" as="xs:double">
+ <xsl:iterate select="1 to $limit">
+ <xsl:param name="result" select="1" as="xs:double"/>
+ <xsl:on-completion>
+ <xsl:sequence select="$result"/>
+ </xsl:on-completion>
+ <xsl:next-iteration>
+ <xsl:with-param name="result" select="$result + (1 div fn0:factorial(.))" as="xs:double"/>
+ </xsl:next-iteration>
+ </xsl:iterate>
+ </xsl:function>
+
+ <!-- An XSL stylesheet function, to find factorial of
+ a positive integer value. -->
+ <xsl:function name="fn0:factorial" as="xs:integer">
+ <xsl:param name="n" as="xs:integer"/>
+ <xsl:sequence select="if ($n eq 1) then 1 else ($n * fn0:factorial($n - 1))"/>
+ </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