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/12/29 06:26:02 UTC
(xalan-java) branch xalan-j_xslt3.0_mvn updated: committing an xsl 3 test case for xalan-j's implementation of xpath map expression
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 46be78b7e committing an xsl 3 test case for xalan-j's implementation of xpath map expression
46be78b7e is described below
commit 46be78b7e056e3181252a901761e8580e66f95fd
Author: Mukul Gandhi <ga...@gmail.com>
AuthorDate: Sun Dec 29 11:55:49 2024 +0530
committing an xsl 3 test case for xalan-j's implementation of xpath map expression
---
.../apache/xalan/tests/xpath3/XPathMapTests.java | 10 +++
src/test/resources/xpath_maps/gold/test30.out | 7 ++
src/test/resources/xpath_maps/test30.xsl | 83 ++++++++++++++++++++++
3 files changed, 100 insertions(+)
diff --git a/src/test/java/org/apache/xalan/tests/xpath3/XPathMapTests.java b/src/test/java/org/apache/xalan/tests/xpath3/XPathMapTests.java
index 103222479..e7c76833f 100644
--- a/src/test/java/org/apache/xalan/tests/xpath3/XPathMapTests.java
+++ b/src/test/java/org/apache/xalan/tests/xpath3/XPathMapTests.java
@@ -337,5 +337,15 @@ public class XPathMapTests extends XSLTransformTestsUtil {
runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
}
+
+ @Test
+ public void xslMapTest30() {
+ String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test30.xsl";
+ String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test30.xsl";
+
+ String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test30.out";
+
+ runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+ }
}
diff --git a/src/test/resources/xpath_maps/gold/test30.out b/src/test/resources/xpath_maps/gold/test30.out
new file mode 100644
index 000000000..b1ec18439
--- /dev/null
+++ b/src/test/resources/xpath_maps/gold/test30.out
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?><book>
+ <title>Data on the Web</title>
+ <year>2000</year>
+ <author>Abiteboul Abiteboul, Buneman Buneman, Suciu Suciu</author>
+ <publisher>Morgan Kaufmann Publishers</publisher>
+ <price>39.95</price>
+</book>
diff --git a/src/test/resources/xpath_maps/test30.xsl b/src/test/resources/xpath_maps/test30.xsl
new file mode 100644
index 000000000..cae89e40d
--- /dev/null
+++ b/src/test/resources/xpath_maps/test30.xsl
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:array="http://www.w3.org/2005/xpath-functions/array"
+ exclude-result-prefixes="array"
+ version="3.0">
+
+ <!-- Author: mukulg@apache.org -->
+
+ <!-- An XSL stylesheet test case to test, XPath map expression.
+ The XPath map expression example used within this test case,
+ has been borrowed from XPath 3.1 spec.
+ -->
+
+ <xsl:output method="xml" indent="yes"/>
+
+ <xsl:template match="/">
+ <xsl:variable name="map1" select="map {
+ 'book': map {
+ 'title' : 'Data on the Web',
+ 'year' : 2000,
+ 'author' : [
+ map {
+ 'last' : 'Abiteboul',
+ 'first' : 'Serge'
+ },
+ map {
+ 'last' : 'Buneman',
+ 'first' : 'Peter'
+ },
+ map {
+ 'last' : 'Suciu',
+ 'first' : 'Dan'
+ }
+ ],
+ 'publisher': 'Morgan Kaufmann Publishers',
+ 'price': 39.95
+ }
+ }" />
+ <book>
+ <xsl:variable name="bookVar1" select="$map1('book')" as="map(*)"/>
+ <title>
+ <xsl:value-of select="$bookVar1('title')"/>
+ </title>
+ <year>
+ <xsl:value-of select="$bookVar1('year')"/>
+ </year>
+ <author>
+ <xsl:variable name="bookAuthorVar1" select="$bookVar1('author')" as="array(*)"/>
+ <xsl:for-each select="1 to array:size($bookAuthorVar1)">
+ <xsl:variable name="bookAuthor" select="array:get($bookAuthorVar1, .)" as="map(*)"/>
+ <xsl:value-of select="if (. lt array:size($bookAuthorVar1)) then ($bookAuthor('first') || ' ' || $bookAuthor('last') || ', ')
+ else
+ ($bookAuthor('first') || ' ' || $bookAuthor('last'))"/>
+ </xsl:for-each>
+ </author>
+ <publisher>
+ <xsl:value-of select="$bookVar1('publisher')"/>
+ </publisher>
+ <price>
+ <xsl:value-of select="$bookVar1('price')"/>
+ </price>
+ </book>
+ </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>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xalan.apache.org
For additional commands, e-mail: commits-help@xalan.apache.org