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/03/10 17:24:42 UTC
(xalan-java) branch xalan-j_xslt3.0_mvn updated: committing a new working test case for xpath 3.1 function fn:sort, using an explicit argument for sort key
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 6063833bc committing a new working test case for xpath 3.1 function fn:sort, using an explicit argument for sort key
6063833bc is described below
commit 6063833bc97f84c97f9303151ff23ae38e7c3177
Author: Mukul Gandhi <ga...@gmail.com>
AuthorDate: Mon Mar 10 22:54:26 2025 +0530
committing a new working test case for xpath 3.1 function fn:sort, using an explicit argument for sort key
---
.../org/apache/xalan/tests/xpath3/FnSortTests.java | 10 ++++
src/test/resources/fn_sort/gold/test19.out | 30 +++++++++++
src/test/resources/fn_sort/test22.xsl | 61 ++++++++++++++++++++++
3 files changed, 101 insertions(+)
diff --git a/src/test/java/org/apache/xalan/tests/xpath3/FnSortTests.java b/src/test/java/org/apache/xalan/tests/xpath3/FnSortTests.java
index 90398100a..d34af80cb 100644
--- a/src/test/java/org/apache/xalan/tests/xpath3/FnSortTests.java
+++ b/src/test/java/org/apache/xalan/tests/xpath3/FnSortTests.java
@@ -258,5 +258,15 @@ public class FnSortTests extends XSLTransformTestsUtil {
runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
}
+
+ @Test
+ public void xslFnSortTest22() {
+ String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test22.xsl";
+ String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test22.xsl";
+
+ String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test19.out";
+
+ runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+ }
}
diff --git a/src/test/resources/fn_sort/gold/test19.out b/src/test/resources/fn_sort/gold/test19.out
new file mode 100644
index 000000000..040bbe40a
--- /dev/null
+++ b/src/test/resources/fn_sort/gold/test19.out
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?><result>
+ <items sortedOrder="ascending_by_yrMonth">
+ <item>
+ <id>2</id>
+ <yrMonth>2005-03</yrMonth>
+ </item>
+ <item>
+ <id>3</id>
+ <yrMonth>2005-07</yrMonth>
+ </item>
+ <item>
+ <id>1</id>
+ <yrMonth>2005-10</yrMonth>
+ </item>
+ </items>
+ <items sortedOrder="descending_by_yrMonth">
+ <item>
+ <id>1</id>
+ <yrMonth>2005-10</yrMonth>
+ </item>
+ <item>
+ <id>3</id>
+ <yrMonth>2005-07</yrMonth>
+ </item>
+ <item>
+ <id>2</id>
+ <yrMonth>2005-03</yrMonth>
+ </item>
+ </items>
+</result>
diff --git a/src/test/resources/fn_sort/test22.xsl b/src/test/resources/fn_sort/test22.xsl
new file mode 100644
index 000000000..9b0a659a5
--- /dev/null
+++ b/src/test/resources/fn_sort/test22.xsl
@@ -0,0 +1,61 @@
+<?xml version="1.0"?>
+<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 XSL 3 stylesheet test case, to test XPath 3.1 function fn:sort
+ using an explicit argument for sort key which is a function definition,
+ to sort sequence of input items by xs:gYearMonth values. Both ascending
+ and descending sort orders are tested by this XSL stylesheet.
+ -->
+
+ <xsl:output method="xml" indent="yes"/>
+
+ <xsl:variable name="nodeSet1">
+ <item>
+ <id>1</id>
+ <yrMonth>2005-10</yrMonth>
+ </item>
+ <item>
+ <id>2</id>
+ <yrMonth>2005-03</yrMonth>
+ </item>
+ <item>
+ <id>3</id>
+ <yrMonth>2005-07</yrMonth>
+ </item>
+ </xsl:variable>
+
+ <xsl:template match="/">
+ <result>
+ <items sortedOrder="ascending_by_yrMonth">
+ <xsl:copy-of select="sort($nodeSet1/item, (), function($item) {xs:gYearMonth($item/yrMonth)})"/>
+ </items>
+ <items sortedOrder="descending_by_yrMonth">
+ <xsl:copy-of select="reverse(sort($nodeSet1/item, (), function($item) {xs:gYearMonth($item/yrMonth)}))"/>
+ </items>
+ </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