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 2024/01/11 08:36:58 UTC
(xalan-java) branch xalan-j_xslt3.0 updated: adding few new working test cases, for an xslt 3.0 and xpath 3.1 article that is available on the site www.xml.com
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 82241cc2 adding few new working test cases, for an xslt 3.0 and xpath 3.1 article that is available on the site www.xml.com
new fd522f2d Merge pull request #156 from mukulga/xalan-j_xslt3.0_mukul
82241cc2 is described below
commit 82241cc2ed0053a8b4aefd2e4edc3d84fbbf8a9d
Author: Mukul Gandhi <ga...@gmail.com>
AuthorDate: Thu Jan 11 13:59:59 2024 +0530
adding few new working test cases, for an xslt 3.0 and xpath 3.1 article that is available on the site www.xml.com
---
.../xslt3/XmlDotComHigherOrderFunctionsTests.java | 167 +++++++++++++++++++++
tests/org/apache/xalan/xslt3/Xsl3TestSuite1.java | 3 +-
.../gold/test1.out | 5 +
.../gold/test10.out | 10 ++
.../gold/test11.out | 6 +
.../gold/test2.out | 7 +
.../gold/test3.out | 7 +
.../gold/test4.out | 7 +
.../gold/test5.out | 5 +
.../gold/test6.out | 7 +
.../gold/test7.out | 5 +
.../gold/test8.out | 21 +++
.../gold/test9.out | 7 +
.../xml1.xml | 5 +
.../xml2.xml | 7 +
.../xml3.xml | 5 +
.../xml4.xml | 14 ++
.../xml5.xml | 11 ++
.../xml6.xml | 11 ++
.../xsl1.xsl | 41 +++++
.../xsl10.xsl | 41 +++++
.../xsl11.xsl | 58 +++++++
.../xsl2.xsl | 52 +++++++
.../xsl3.xsl | 48 ++++++
.../xsl4.xsl | 52 +++++++
.../xsl5.xsl | 58 +++++++
.../xsl6.xsl | 52 +++++++
.../xsl7.xsl | 45 ++++++
.../xsl8.xsl | 68 +++++++++
.../xsl9.xsl | 37 +++++
30 files changed, 861 insertions(+), 1 deletion(-)
diff --git a/tests/org/apache/xalan/xslt3/XmlDotComHigherOrderFunctionsTests.java b/tests/org/apache/xalan/xslt3/XmlDotComHigherOrderFunctionsTests.java
new file mode 100644
index 00000000..6e20bfe3
--- /dev/null
+++ b/tests/org/apache/xalan/xslt3/XmlDotComHigherOrderFunctionsTests.java
@@ -0,0 +1,167 @@
+/*
+ * 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.
+ */
+package org.apache.xalan.xslt3;
+
+import org.apache.xalan.util.XslTransformTestsUtil;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * XSLT 3.0 test cases, to test XPath 3.1 higher order functions (HOF).
+ *
+ * These XSLT test cases, are for XSLT and XPath examples available within
+ * following XSLT and XPath HOF article published on www.xml.com :
+ * https://www.xml.com/articles/2023/12/05/xml-path-language-xpath-higher-order-functions/.
+ *
+ *
+ * @author Mukul Gandhi <mu...@apache.org>
+ *
+ * @xsl.usage advanced
+ */
+public class XmlDotComHigherOrderFunctionsTests extends XslTransformTestsUtil {
+
+ private static final String XSL_TRANSFORM_INPUT_DIRPATH = XSLConstants.XSL_TRANSFORM_INPUT_DIRPATH_PREFIX +
+ "xml_dot_com_higher_order_functions_tests/";
+
+ private static final String XSL_TRANSFORM_GOLD_DIRPATH = XSLConstants.XSL_TRANSFORM_GOLD_DIRPATH_PREFIX +
+ "xml_dot_com_higher_order_functions_tests/gold/";
+
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ // no op
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ xmlDocumentBuilderFactory = null;
+ xmlDocumentBuilder = null;
+ xslTransformerFactory = null;
+ }
+
+ @Test
+ public void xslXmlDotComHofTest1() {
+ String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "xml1.xml";
+ String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "xsl1.xsl";
+
+ String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test1.out";
+
+ runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+ }
+
+ @Test
+ public void xslXmlDotComHofTest2() {
+ String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "xml2.xml";
+ String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "xsl2.xsl";
+
+ String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test2.out";
+
+ runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+ }
+
+ @Test
+ public void xslXmlDotComHofTest3() {
+ String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "xml2.xml";
+ String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "xsl3.xsl";
+
+ String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test3.out";
+
+ runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+ }
+
+ @Test
+ public void xslXmlDotComHofTest4() {
+ String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "xml2.xml";
+ String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "xsl4.xsl";
+
+ String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test4.out";
+
+ runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+ }
+
+ @Test
+ public void xslXmlDotComHofTest5() {
+ String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "xml3.xml";
+ String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "xsl5.xsl";
+
+ String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test5.out";
+
+ runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+ }
+
+ @Test
+ public void xslXmlDotComHofTest6() {
+ String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "xml6.xml";
+ String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "xsl6.xsl";
+
+ String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test6.out";
+
+ runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+ }
+
+ @Test
+ public void xslXmlDotComHofTest7() {
+ String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "xsl7.xsl";
+ String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "xsl7.xsl";
+
+ String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test7.out";
+
+ runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+ }
+
+ @Test
+ public void xslXmlDotComHofTest8() {
+ String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "xml4.xml";
+ String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "xsl8.xsl";
+
+ String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test8.out";
+
+ runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+ }
+
+ @Test
+ public void xslXmlDotComHofTest9() {
+ String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "xml5.xml";
+ String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "xsl9.xsl";
+
+ String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test9.out";
+
+ runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+ }
+
+ @Test
+ public void xslXmlDotComHofTest10() {
+ String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "xml6.xml";
+ String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "xsl10.xsl";
+
+ String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test10.out";
+
+ runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+ }
+
+ @Test
+ public void xslXmlDotComHofTest11() {
+ String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "xsl11.xsl";
+ String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "xsl11.xsl";
+
+ String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test11.out";
+
+ runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+ }
+
+}
diff --git a/tests/org/apache/xalan/xslt3/Xsl3TestSuite1.java b/tests/org/apache/xalan/xslt3/Xsl3TestSuite1.java
index 07ac7e30..ae111575 100644
--- a/tests/org/apache/xalan/xslt3/Xsl3TestSuite1.java
+++ b/tests/org/apache/xalan/xslt3/Xsl3TestSuite1.java
@@ -48,7 +48,8 @@ import org.junit.runners.Suite.SuiteClasses;
FnForEachTests.class, XsConstructorFunctionTests.class,
FnAbsTests.class, StringTests.class, XsDateTimeArithmeticTests.class,
XsTimeWithArithmeticTests.class, XsDurationSubtypes.class,
- FnDeepEqualTests.class, XSLImportSchemaTests.class, FnDateTimeTests.class })
+ FnDeepEqualTests.class, XSLImportSchemaTests.class, FnDateTimeTests.class,
+ XmlDotComHigherOrderFunctionsTests.class })
public class Xsl3TestSuite1 {
}
diff --git a/tests/xml_dot_com_higher_order_functions_tests/gold/test1.out b/tests/xml_dot_com_higher_order_functions_tests/gold/test1.out
new file mode 100644
index 00000000..4a7145ad
--- /dev/null
+++ b/tests/xml_dot_com_higher_order_functions_tests/gold/test1.out
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?><result>
+ <val contentLength="2" id="1">hi</val>
+ <val contentLength="5" id="2">hello</val>
+ <val contentLength="5" id="3">there</val>
+</result>
diff --git a/tests/xml_dot_com_higher_order_functions_tests/gold/test10.out b/tests/xml_dot_com_higher_order_functions_tests/gold/test10.out
new file mode 100644
index 00000000..2f6bb5d4
--- /dev/null
+++ b/tests/xml_dot_com_higher_order_functions_tests/gold/test10.out
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?><result>
+ <res>3</res>
+ <res>5</res>
+ <res>7</res>
+ <res>9</res>
+ <res>11</res>
+ <res>13</res>
+ <res>15</res>
+ <res>17</res>
+</result>
diff --git a/tests/xml_dot_com_higher_order_functions_tests/gold/test11.out b/tests/xml_dot_com_higher_order_functions_tests/gold/test11.out
new file mode 100644
index 00000000..d8e6e6f7
--- /dev/null
+++ b/tests/xml_dot_com_higher_order_functions_tests/gold/test11.out
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?><result>
+ <one>9</one>
+ <two>5</two>
+ <three>14</three>
+ <four>3.5</four>
+</result>
diff --git a/tests/xml_dot_com_higher_order_functions_tests/gold/test2.out b/tests/xml_dot_com_higher_order_functions_tests/gold/test2.out
new file mode 100644
index 00000000..06be1a8e
--- /dev/null
+++ b/tests/xml_dot_com_higher_order_functions_tests/gold/test2.out
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?><result>
+ <valOdd id="1">hi</valOdd>
+ <valEven id="2">hello</valEven>
+ <valOdd id="3">there</valOdd>
+ <valEven id="4">that's</valEven>
+ <valOdd id="5">nice</valOdd>
+</result>
diff --git a/tests/xml_dot_com_higher_order_functions_tests/gold/test3.out b/tests/xml_dot_com_higher_order_functions_tests/gold/test3.out
new file mode 100644
index 00000000..4b820922
--- /dev/null
+++ b/tests/xml_dot_com_higher_order_functions_tests/gold/test3.out
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?><result>
+ <val id="11">hi</val>
+ <val id="12">hello</val>
+ <val id="13">there</val>
+ <val id="14">that's</val>
+ <val id="15">nice</val>
+</result>
diff --git a/tests/xml_dot_com_higher_order_functions_tests/gold/test4.out b/tests/xml_dot_com_higher_order_functions_tests/gold/test4.out
new file mode 100644
index 00000000..4b820922
--- /dev/null
+++ b/tests/xml_dot_com_higher_order_functions_tests/gold/test4.out
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?><result>
+ <val id="11">hi</val>
+ <val id="12">hello</val>
+ <val id="13">there</val>
+ <val id="14">that's</val>
+ <val id="15">nice</val>
+</result>
diff --git a/tests/xml_dot_com_higher_order_functions_tests/gold/test5.out b/tests/xml_dot_com_higher_order_functions_tests/gold/test5.out
new file mode 100644
index 00000000..f1df75e5
--- /dev/null
+++ b/tests/xml_dot_com_higher_order_functions_tests/gold/test5.out
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?><result>
+ <res1>12</res1>
+ <res2>8</res2>
+ <res3>20</res3>
+</result>
diff --git a/tests/xml_dot_com_higher_order_functions_tests/gold/test6.out b/tests/xml_dot_com_higher_order_functions_tests/gold/test6.out
new file mode 100644
index 00000000..a6582b0c
--- /dev/null
+++ b/tests/xml_dot_com_higher_order_functions_tests/gold/test6.out
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?><result>
+ <temperature degrees="5">41</temperature>
+ <temperature degrees="10.2">50.36</temperature>
+ <temperature degrees="15">59</temperature>
+ <temperature degrees="20.7">69.26</temperature>
+ <temperature degrees="25">77</temperature>
+</result>
diff --git a/tests/xml_dot_com_higher_order_functions_tests/gold/test7.out b/tests/xml_dot_com_higher_order_functions_tests/gold/test7.out
new file mode 100644
index 00000000..9c69e2b7
--- /dev/null
+++ b/tests/xml_dot_com_higher_order_functions_tests/gold/test7.out
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?><result>
+ <one>7</one>
+ <two>11</two>
+ <three>17</three>
+</result>
diff --git a/tests/xml_dot_com_higher_order_functions_tests/gold/test8.out b/tests/xml_dot_com_higher_order_functions_tests/gold/test8.out
new file mode 100644
index 00000000..40916317
--- /dev/null
+++ b/tests/xml_dot_com_higher_order_functions_tests/gold/test8.out
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?><result>
+ <groupsStart/>
+ <valElems priority="2">
+ <val b="2" a="1"/>
+ <val b="3" a="2"/>
+ <val b="5" a="4"/>
+ <val b="9" a="8"/>
+ </valElems>
+ <valElems priority="1">
+ <val b="4" a="3"/>
+ <val b="6" a="5"/>
+ <val b="7" a="6"/>
+ <val b="8" a="7"/>
+ </valElems>
+ <valElems priority="3">
+ <val b="2" a="1"/>
+ <val b="3" a="2"/>
+ <val b="4" a="3"/>
+ </valElems>
+ <groupsEnd/>
+</result>
diff --git a/tests/xml_dot_com_higher_order_functions_tests/gold/test9.out b/tests/xml_dot_com_higher_order_functions_tests/gold/test9.out
new file mode 100644
index 00000000..d4bc4014
--- /dev/null
+++ b/tests/xml_dot_com_higher_order_functions_tests/gold/test9.out
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?><result>
+ <val>1.1</val>
+ <val>2.1</val>
+ <val>3.1</val>
+ <val>4.1</val>
+ <val>5.1</val>
+</result>
diff --git a/tests/xml_dot_com_higher_order_functions_tests/xml1.xml b/tests/xml_dot_com_higher_order_functions_tests/xml1.xml
new file mode 100644
index 00000000..43b274fb
--- /dev/null
+++ b/tests/xml_dot_com_higher_order_functions_tests/xml1.xml
@@ -0,0 +1,5 @@
+<info>
+ <val id="1">hi</val>
+ <val id="2">hello</val>
+ <val id="3">there</val>
+</info>
\ No newline at end of file
diff --git a/tests/xml_dot_com_higher_order_functions_tests/xml2.xml b/tests/xml_dot_com_higher_order_functions_tests/xml2.xml
new file mode 100644
index 00000000..3e0e5780
--- /dev/null
+++ b/tests/xml_dot_com_higher_order_functions_tests/xml2.xml
@@ -0,0 +1,7 @@
+<info>
+ <val id="1">hi</val>
+ <val id="2">hello</val>
+ <val id="3">there</val>
+ <val id="4">that's</val>
+ <val id="5">nice</val>
+</info>
\ No newline at end of file
diff --git a/tests/xml_dot_com_higher_order_functions_tests/xml3.xml b/tests/xml_dot_com_higher_order_functions_tests/xml3.xml
new file mode 100644
index 00000000..e9e9117d
--- /dev/null
+++ b/tests/xml_dot_com_higher_order_functions_tests/xml3.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<info>
+ <val1>10</val1>
+ <val2>2</val2>
+</info>
\ No newline at end of file
diff --git a/tests/xml_dot_com_higher_order_functions_tests/xml4.xml b/tests/xml_dot_com_higher_order_functions_tests/xml4.xml
new file mode 100644
index 00000000..60080ee6
--- /dev/null
+++ b/tests/xml_dot_com_higher_order_functions_tests/xml4.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<info>
+ <val priority="2" a="1" b="2"/>
+ <val priority="2" a="2" b="3"/>
+ <val priority="1" a="3" b="4"/>
+ <val priority="2" a="4" b="5"/>
+ <val priority="3" a="1" b="2"/>
+ <val priority="3" a="2" b="3"/>
+ <val priority="3" a="3" b="4"/>
+ <val priority="1" a="5" b="6"/>
+ <val priority="1" a="6" b="7"/>
+ <val priority="1" a="7" b="8"/>
+ <val priority="2" a="8" b="9"/>
+</info>
\ No newline at end of file
diff --git a/tests/xml_dot_com_higher_order_functions_tests/xml5.xml b/tests/xml_dot_com_higher_order_functions_tests/xml5.xml
new file mode 100644
index 00000000..72f92b13
--- /dev/null
+++ b/tests/xml_dot_com_higher_order_functions_tests/xml5.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<info>
+ <val>1.1</val>
+ <val>2.1</val>
+ <val>3.1</val>
+ <val>4.1</val>
+ <val>5.1</val>
+ <val>6.1</val>
+ <val>7.1</val>
+ <val>8.1</val>
+</info>
\ No newline at end of file
diff --git a/tests/xml_dot_com_higher_order_functions_tests/xml6.xml b/tests/xml_dot_com_higher_order_functions_tests/xml6.xml
new file mode 100644
index 00000000..7064d56d
--- /dev/null
+++ b/tests/xml_dot_com_higher_order_functions_tests/xml6.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<info>
+ <val a="1" b="2"/>
+ <val a="2" b="3"/>
+ <val a="3" b="4"/>
+ <val a="4" b="5"/>
+ <val a="5" b="6"/>
+ <val a="6" b="7"/>
+ <val a="7" b="8"/>
+ <val a="8" b="9"/>
+</info>
\ No newline at end of file
diff --git a/tests/xml_dot_com_higher_order_functions_tests/xsl1.xsl b/tests/xml_dot_com_higher_order_functions_tests/xsl1.xsl
new file mode 100644
index 00000000..63e72343
--- /dev/null
+++ b/tests/xml_dot_com_higher_order_functions_tests/xsl1.xsl
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ version="3.0">
+
+ <!-- Author: mukulg@apache.org -->
+
+ <!-- use with xml1.xml -->
+
+ <xsl:output method="xml" indent="yes"/>
+
+ <xsl:template match="/info">
+ <result>
+ <xsl:apply-templates select="val"/>
+ </result>
+ </xsl:template>
+
+ <xsl:template match="val">
+ <val id="{@id}" contentLength="{string-length(.)}">
+ <xsl:value-of select="."/>
+ </val>
+ </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/xml_dot_com_higher_order_functions_tests/xsl10.xsl b/tests/xml_dot_com_higher_order_functions_tests/xsl10.xsl
new file mode 100644
index 00000000..948f04f4
--- /dev/null
+++ b/tests/xml_dot_com_higher_order_functions_tests/xsl10.xsl
@@ -0,0 +1,41 @@
+<?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 -->
+
+ <!-- use with xml6.xml -->
+
+ <xsl:output method="xml" indent="yes"/>
+
+ <xsl:template match="/info">
+ <result>
+ <xsl:for-each select="for-each-pair(val/@a, val/@b, function($a, $b) { xs:double($a) + xs:double($b) })">
+ <res>
+ <xsl:value-of select="."/>
+ </res>
+ </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/xml_dot_com_higher_order_functions_tests/xsl11.xsl b/tests/xml_dot_com_higher_order_functions_tests/xsl11.xsl
new file mode 100644
index 00000000..08786bfb
--- /dev/null
+++ b/tests/xml_dot_com_higher_order_functions_tests/xsl11.xsl
@@ -0,0 +1,58 @@
+<?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 -->
+
+ <xsl:output method="xml" indent="yes"/>
+
+ <xsl:variable name="binaryOp" select="function($f1 as function(*),
+ $a as xs:double,
+ $b as xs:double) as xs:double { $f1($a, $b) }"/>
+
+ <xsl:variable name="add" select="function($a as xs:double, $b as xs:double) as xs:double { $a + $b }"/>
+
+ <xsl:variable name="subtract" select="function($a as xs:double, $b as xs:double) as xs:double { $a - $b }"/>
+
+ <xsl:variable name="multiply" select="function($a as xs:double, $b as xs:double) as xs:double { $a * $b }"/>
+
+ <xsl:variable name="divide" select="function($a as xs:double, $b as xs:double) as xs:double { $a div $b }"/>
+
+ <xsl:template match="/">
+ <result>
+ <one>
+ <xsl:value-of select="$binaryOp($add, 7, 2)"/>
+ </one>
+ <two>
+ <xsl:value-of select="$binaryOp($subtract, 7, 2)"/>
+ </two>
+ <three>
+ <xsl:value-of select="$binaryOp($multiply, 7, 2)"/>
+ </three>
+ <four>
+ <xsl:value-of select="$binaryOp($divide, 7, 2)"/>
+ </four>
+ </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/xml_dot_com_higher_order_functions_tests/xsl2.xsl b/tests/xml_dot_com_higher_order_functions_tests/xsl2.xsl
new file mode 100644
index 00000000..fb91082e
--- /dev/null
+++ b/tests/xml_dot_com_higher_order_functions_tests/xsl2.xsl
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ version="3.0">
+
+ <!-- Author: mukulg@apache.org -->
+
+ <!-- use with xml2.xml -->
+
+ <xsl:output method="xml" indent="yes"/>
+
+ <xsl:template match="/info">
+ <result>
+ <xsl:apply-templates select="val"/>
+ </result>
+ </xsl:template>
+
+ <xsl:template match="val" as="element()">
+ <xsl:choose>
+ <xsl:when test="(@id mod 2) eq 0">
+ <valEven>
+ <xsl:copy-of select="@id"/>
+ <xsl:value-of select="."/>
+ </valEven>
+ </xsl:when>
+ <xsl:otherwise>
+ <valOdd>
+ <xsl:copy-of select="@id"/>
+ <xsl:value-of select="."/>
+ </valOdd>
+ </xsl:otherwise>
+ </xsl:choose>
+ </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/xml_dot_com_higher_order_functions_tests/xsl3.xsl b/tests/xml_dot_com_higher_order_functions_tests/xsl3.xsl
new file mode 100644
index 00000000..763f5a5e
--- /dev/null
+++ b/tests/xml_dot_com_higher_order_functions_tests/xsl3.xsl
@@ -0,0 +1,48 @@
+<?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 -->
+
+ <!-- use with xml2.xml -->
+
+ <xsl:output method="xml" indent="yes"/>
+
+ <xsl:template match="/info">
+ <result>
+ <xsl:variable name="c1" select="10" as="xs:integer"/>
+ <xsl:apply-templates select="val">
+ <xsl:with-param name="c1Val" select="$c1" as="xs:integer"/>
+ </xsl:apply-templates>
+ </result>
+ </xsl:template>
+
+ <xsl:template match="val" as="element(val)">
+ <xsl:param name="c1Val" as="xs:integer"/>
+ <val>
+ <xsl:attribute name="id" select="@id + $c1Val"/>
+ <xsl:value-of select="."/>
+ </val>
+ </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/xml_dot_com_higher_order_functions_tests/xsl4.xsl b/tests/xml_dot_com_higher_order_functions_tests/xsl4.xsl
new file mode 100644
index 00000000..741948d1
--- /dev/null
+++ b/tests/xml_dot_com_higher_order_functions_tests/xsl4.xsl
@@ -0,0 +1,52 @@
+<?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 -->
+
+ <!-- use with xml2.xml -->
+
+ <xsl:output method="xml" indent="yes"/>
+
+ <xsl:template match="/info">
+ <result>
+ <xsl:variable name="c1" select="10" as="xs:integer"/>
+ <xsl:for-each select="val">
+ <xsl:call-template name="processValElem">
+ <xsl:with-param name="valElem" select="." as="element(val)"/>
+ <xsl:with-param name="c1Val" select="$c1" as="xs:integer"/>
+ </xsl:call-template>
+ </xsl:for-each>
+ </result>
+ </xsl:template>
+
+ <xsl:template name="processValElem" as="element(val)">
+ <xsl:param name="valElem" as="element(val)"/>
+ <xsl:param name="c1Val" as="xs:integer"/>
+ <val>
+ <xsl:attribute name="id" select="$valElem/@id + $c1Val"/>
+ <xsl:value-of select="$valElem"/>
+ </val>
+ </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/xml_dot_com_higher_order_functions_tests/xsl5.xsl b/tests/xml_dot_com_higher_order_functions_tests/xsl5.xsl
new file mode 100644
index 00000000..6b6436f9
--- /dev/null
+++ b/tests/xml_dot_com_higher_order_functions_tests/xsl5.xsl
@@ -0,0 +1,58 @@
+<?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:fn1="http://fn1"
+ exclude-result-prefixes="xs fn1"
+ version="3.0">
+
+ <!-- Author: mukulg@apache.org -->
+
+ <!-- use with xml3.xml -->
+
+ <xsl:output method="xml" indent="yes"/>
+
+ <xsl:template match="/info">
+ <result>
+ <res1>
+ <xsl:value-of select="fn1:binaryOp(function($a as xs:integer, $b as xs:integer) as xs:integer { $a + $b }, val1, val2)"/>
+ </res1>
+ <res2>
+ <xsl:value-of select="fn1:binaryOp(function($a as xs:integer, $b as xs:integer) as xs:integer { $a - $b }, val1, val2)"/>
+ </res2>
+ <res3>
+ <xsl:value-of select="fn1:binaryOp(function($a as xs:integer, $b as xs:integer) as xs:integer { $a * $b }, val1, val2)"/>
+ </res3>
+ </result>
+ </xsl:template>
+
+ <!-- A stylesheet function (that works as a generic logical binary operator implemented by this stylesheet function), that has
+ three parameters. The first parameter is a function item (that accepts two integer arguments, and returns an integer result).
+ The other two parameters of this stylesheet function are integer paramaters, that're provided as arguments to the function
+ item parameter.
+ -->
+ <xsl:function name="fn1:binaryOp" as="xs:integer">
+ <xsl:param name="f1" as="function(xs:integer, xs:integer) as xs:integer"/>
+ <xsl:param name="a" as="xs:integer"/>
+ <xsl:param name="b" as="xs:integer"/>
+ <xsl:sequence select="$f1($a, $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/xml_dot_com_higher_order_functions_tests/xsl6.xsl b/tests/xml_dot_com_higher_order_functions_tests/xsl6.xsl
new file mode 100644
index 00000000..20da9c08
--- /dev/null
+++ b/tests/xml_dot_com_higher_order_functions_tests/xsl6.xsl
@@ -0,0 +1,52 @@
+<?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:fn1="http://fn1"
+ exclude-result-prefixes="xs fn1"
+ version="3.0">
+
+ <!-- Author: mukulg@apache.org -->
+
+ <xsl:output method="xml" indent="yes"/>
+
+ <xsl:variable name="degreeCelsiusTemps" select="(5, 10.2, 15, 20.7, 25)" as="xs:double*"/>
+
+ <xsl:template match="/">
+ <result>
+ <xsl:for-each select="$degreeCelsiusTemps">
+ <xsl:variable name="degreesTemp" select="."/>
+ <temperature degrees="{$degreesTemp}">
+ <xsl:value-of select="fn1:degreeCelsiusToFahrenheit($degreesTemp)"/>
+ </temperature>
+ </xsl:for-each>
+ </result>
+ </xsl:template>
+
+ <!-- A stylesheet function, that converts a degrees celsius temperature value
+ to fahrenheit temperature value, and rounds the result to two decimal
+ places.
+ -->
+ <xsl:function name="fn1:degreeCelsiusToFahrenheit" as="xs:double">
+ <xsl:param name="c1" as="xs:double"/>
+ <xsl:sequence select="round(($c1 * (9 div 5)) + 32, 2)"/>
+ </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/xml_dot_com_higher_order_functions_tests/xsl7.xsl b/tests/xml_dot_com_higher_order_functions_tests/xsl7.xsl
new file mode 100644
index 00000000..d3a6f7ee
--- /dev/null
+++ b/tests/xml_dot_com_higher_order_functions_tests/xsl7.xsl
@@ -0,0 +1,45 @@
+<?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 -->
+
+ <xsl:output method="xml" indent="yes"/>
+
+ <xsl:variable name="func1" select="function ($a as xs:integer, $b as xs:integer) as xs:integer { ($a * $b) + 5 }"/>
+
+ <xsl:template match="/">
+ <result>
+ <one>
+ <xsl:value-of select="$func1(1, 2)"/>
+ </one>
+ <two>
+ <xsl:value-of select="$func1(2, 3)"/>
+ </two>
+ <three>
+ <xsl:value-of select="$func1(3, 4)"/>
+ </three>
+ </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/xml_dot_com_higher_order_functions_tests/xsl8.xsl b/tests/xml_dot_com_higher_order_functions_tests/xsl8.xsl
new file mode 100644
index 00000000..044582bd
--- /dev/null
+++ b/tests/xml_dot_com_higher_order_functions_tests/xsl8.xsl
@@ -0,0 +1,68 @@
+<?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="xs fn0"
+ version="3.0">
+
+ <!-- Author: mukulg@apache.org -->
+
+ <!-- use with xml4.xml -->
+
+ <xsl:output method="xml" indent="yes"/>
+
+ <!-- A variable referring to an, XPath inline function expression -->
+ <xsl:variable name="constructGrpResultWithDelims" select="function($prefixDelimElemName as xs:string,
+ $suffixDelimElemName as xs:string,
+ $valElems as element(val)*) as element()*
+ { (fn0:constructDelimElem($prefixDelimElemName),
+ fn0:groupValElemsByPriority($valElems),
+ fn0:constructDelimElem($suffixDelimElemName))
+ }"/>
+
+ <xsl:template match="/info">
+ <result>
+ <xsl:copy-of select="$constructGrpResultWithDelims('groupsStart', 'groupsEnd', val)"/>
+ </result>
+ </xsl:template>
+
+ <!-- A stylesheet function, that constructs an XML element given an element's name. -->
+ <xsl:function name="fn0:constructDelimElem" as="element()">
+ <xsl:param name="delimElemName" as="xs:string"/>
+ <xsl:element name="{$delimElemName}"/>
+ </xsl:function>
+
+ <!-- A stylesheet function, that groups (via xsl:for-each-group instruction) a sequence of
+ XML 'val' elements by the specified grouping criteria (via xsl:for-each-group
+ instruction's "group-by" attribute).
+ -->
+ <xsl:function name="fn0:groupValElemsByPriority" as="element(valElems)*">
+ <xsl:param name="valElems" as="element(val)*"/>
+ <xsl:for-each-group select="$valElems" group-by="xs:integer(@priority)">
+ <valElems priority="{current-grouping-key()}">
+ <xsl:for-each select="current-group()">
+ <val a="{@a}" b="{@b}"/>
+ </xsl:for-each>
+ </valElems>
+ </xsl:for-each-group>
+ </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/xml_dot_com_higher_order_functions_tests/xsl9.xsl b/tests/xml_dot_com_higher_order_functions_tests/xsl9.xsl
new file mode 100644
index 00000000..c7db6a17
--- /dev/null
+++ b/tests/xml_dot_com_higher_order_functions_tests/xsl9.xsl
@@ -0,0 +1,37 @@
+<?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 -->
+
+ <!-- use with xml5.xml -->
+
+ <xsl:output method="xml" indent="yes"/>
+
+ <xsl:template match="/info">
+ <result>
+ <xsl:copy-of select="filter(val, function($elem) { xs:double($elem/text()) lt 6 })"/>
+ </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
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xalan.apache.org
For additional commands, e-mail: commits-help@xalan.apache.org