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/14 17:55:11 UTC
(xalan-java) branch xalan-j_xslt3.0 updated: adding few new working w3c xslt 3.0 test cases for xpath 3.1 function fn:deep-equal
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 77808c10 adding few new working w3c xslt 3.0 test cases for xpath 3.1 function fn:deep-equal
new c5f3963d Merge pull request #158 from mukulga/xalan-j_xslt3.0_mukul
77808c10 is described below
commit 77808c10ea1399f7807dd71484d263f513b757bd
Author: Mukul Gandhi <ga...@gmail.com>
AuthorDate: Sun Jan 14 23:20:43 2024 +0530
adding few new working w3c xslt 3.0 test cases for xpath 3.1 function fn:deep-equal
---
src/org/apache/xpath/objects/XNodeSet.java | 3 +
.../xpath3/W3c_xslt30_fn_deep_equalTests.java | 72 ++++++++++++++++++++++
tests/org/apache/xalan/xslt3/Xsl3TestSuite2.java | 4 +-
.../fn/deep_equal/gold/test1.out | 5 ++
.../fn/deep_equal/gold/test2.out | 4 ++
tests/w3c_xslt30_testsuite/fn/deep_equal/test1.xsl | 47 ++++++++++++++
.../w3c_xslt30_testsuite/fn/deep_equal/test1_a.xml | 10 +++
tests/w3c_xslt30_testsuite/fn/deep_equal/test2.xsl | 44 +++++++++++++
8 files changed, 188 insertions(+), 1 deletion(-)
diff --git a/src/org/apache/xpath/objects/XNodeSet.java b/src/org/apache/xpath/objects/XNodeSet.java
index 8e5ef143..03f8f88f 100644
--- a/src/org/apache/xpath/objects/XNodeSet.java
+++ b/src/org/apache/xpath/objects/XNodeSet.java
@@ -976,6 +976,9 @@ public class XNodeSet extends NodeSequence
else if ((node1.getNodeType() == Node.TEXT_NODE) && (node2.getNodeType() == Node.TEXT_NODE)) {
isNodeNameEqual = true;
}
+ else if ((node1.getNodeType() == Node.COMMENT_NODE) && (node2.getNodeType() == Node.COMMENT_NODE)) {
+ isNodeNameEqual = true;
+ }
return isNodeNameEqual;
}
diff --git a/tests/org/apache/xalan/xpath3/W3c_xslt30_fn_deep_equalTests.java b/tests/org/apache/xalan/xpath3/W3c_xslt30_fn_deep_equalTests.java
new file mode 100644
index 00000000..4751a3b4
--- /dev/null
+++ b/tests/org/apache/xalan/xpath3/W3c_xslt30_fn_deep_equalTests.java
@@ -0,0 +1,72 @@
+/*
+ * 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.xpath3;
+
+import org.apache.xalan.util.XslTransformTestsUtil;
+import org.apache.xalan.xslt3.XSLConstants;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * XSLT 3.0 test cases for the fn:deep-equal function.
+ *
+ * @author Mukul Gandhi <mu...@apache.org>
+ *
+ * @xsl.usage advanced
+ */
+public class W3c_xslt30_fn_deep_equalTests extends XslTransformTestsUtil {
+
+ private static final String XSL_TRANSFORM_INPUT_DIRPATH = XSLConstants.XSL_TRANSFORM_INPUT_DIRPATH_PREFIX +
+ "w3c_xslt30_testsuite/fn/deep_equal/";
+
+ private static final String XSL_TRANSFORM_GOLD_DIRPATH = XSLConstants.XSL_TRANSFORM_GOLD_DIRPATH_PREFIX +
+ "w3c_xslt30_testsuite/fn/deep_equal/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 xslFnDeepEqualTest1() {
+ String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test1_a.xml";
+ String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test1.xsl";
+
+ String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test1.out";
+
+ runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+ }
+
+ @Test
+ public void xslFnDeepEqualTest2() {
+ String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test1_a.xml";
+ String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test2.xsl";
+
+ String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test2.out";
+
+ runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+ }
+
+}
diff --git a/tests/org/apache/xalan/xslt3/Xsl3TestSuite2.java b/tests/org/apache/xalan/xslt3/Xsl3TestSuite2.java
index b2634d46..3d634088 100644
--- a/tests/org/apache/xalan/xslt3/Xsl3TestSuite2.java
+++ b/tests/org/apache/xalan/xslt3/Xsl3TestSuite2.java
@@ -52,6 +52,7 @@ import org.apache.xalan.xpath3.SequenceTests;
import org.apache.xalan.xpath3.SimpleMapOperatorTests;
import org.apache.xalan.xpath3.StringConcatExprTests;
import org.apache.xalan.xpath3.TrignometricAndExponentialFunctionTests;
+import org.apache.xalan.xpath3.W3c_xslt30_fn_deep_equalTests;
import org.apache.xalan.xpath3.XPathArithmeticOnDurationValuesTests;
import org.apache.xalan.xpath3.XsDurationComponentExtractionFunctionTests;
import org.junit.runner.RunWith;
@@ -70,7 +71,8 @@ import org.junit.runners.Suite.SuiteClasses;
GroupingWithSortTests.class, RtfMigrationTests.class, QuantifiedExprTests.class,
FnUnparsedTextTests.class, FnTokenizeTests.class, FnStringJoinTests.class,
FnIndexOfTests.class, SequenceTests.class, RangeExprTests.class,
- W3c_xslt30_IterateTests.class, W3c_xslt30_AxesTests.class, XslIterateTests.class,
+ W3c_xslt30_IterateTests.class, W3c_xslt30_AxesTests.class,
+ W3c_xslt30_fn_deep_equalTests.class, XslIterateTests.class,
FnFilterTests.class, DynamicFunctionCallTests.class, IfExprTests.class,
ForExprTests.class, LetExprTests.class, FnDistinctValuesTests.class,
TrignometricAndExponentialFunctionTests.class, BuiltinFunctionsNamespceTests.class,
diff --git a/tests/w3c_xslt30_testsuite/fn/deep_equal/gold/test1.out b/tests/w3c_xslt30_testsuite/fn/deep_equal/gold/test1.out
new file mode 100644
index 00000000..5ae9dd6b
--- /dev/null
+++ b/tests/w3c_xslt30_testsuite/fn/deep_equal/gold/test1.out
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?><out>
+ <true>true</true>
+ <false>false</false>
+ <false>false</false>
+</out>
diff --git a/tests/w3c_xslt30_testsuite/fn/deep_equal/gold/test2.out b/tests/w3c_xslt30_testsuite/fn/deep_equal/gold/test2.out
new file mode 100644
index 00000000..de64350d
--- /dev/null
+++ b/tests/w3c_xslt30_testsuite/fn/deep_equal/gold/test2.out
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?><out>
+ <true>true</true>
+ <false>false</false>
+</out>
diff --git a/tests/w3c_xslt30_testsuite/fn/deep_equal/test1.xsl b/tests/w3c_xslt30_testsuite/fn/deep_equal/test1.xsl
new file mode 100644
index 00000000..5963a819
--- /dev/null
+++ b/tests/w3c_xslt30_testsuite/fn/deep_equal/test1.xsl
@@ -0,0 +1,47 @@
+<?xml version="1.0"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ version="3.0">
+
+ <!-- Author: mukulg@apache.org -->
+
+ <!-- use with test1_a.xml -->
+
+ <!-- An XSLT stylesheet test case, to test XPath 3.1
+ fn:deep-equal function.
+ -->
+
+ <xsl:output method="xml" indent="yes"/>
+
+ <xsl:template match="/">
+ <out>
+ <true>
+ <xsl:value-of select="deep-equal(//a[1]/@a, //a[2]/@a)"/>
+ </true>
+ <false>
+ <xsl:value-of select="deep-equal(//a[1]/@a, //b[1]/@a)" />
+ </false>
+ <false>
+ <xsl:value-of select="deep-equal(//a[1]/@a, //c[1]/@c)" />
+ </false>
+ </out>
+ </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>
diff --git a/tests/w3c_xslt30_testsuite/fn/deep_equal/test1_a.xml b/tests/w3c_xslt30_testsuite/fn/deep_equal/test1_a.xml
new file mode 100644
index 00000000..1873e804
--- /dev/null
+++ b/tests/w3c_xslt30_testsuite/fn/deep_equal/test1_a.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<doc>
+<!-- a node -->
+<a a="a"/>
+<!-- a node -->
+<a a="a"/>
+<!-- a few more nodes -->
+<b a="b"/>
+<c c="a"/>
+</doc>
\ No newline at end of file
diff --git a/tests/w3c_xslt30_testsuite/fn/deep_equal/test2.xsl b/tests/w3c_xslt30_testsuite/fn/deep_equal/test2.xsl
new file mode 100644
index 00000000..a2c04927
--- /dev/null
+++ b/tests/w3c_xslt30_testsuite/fn/deep_equal/test2.xsl
@@ -0,0 +1,44 @@
+<?xml version="1.0"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ version="3.0">
+
+ <!-- Author: mukulg@apache.org -->
+
+ <!-- use with test1_a.xml -->
+
+ <!-- An XSLT stylesheet test case, to test XPath 3.1
+ fn:deep-equal function.
+ -->
+
+ <xsl:output method="xml" indent="yes"/>
+
+ <xsl:template match="/">
+ <out>
+ <true>
+ <xsl:value-of select="deep-equal(//comment()[1], //comment()[2])" />
+ </true>
+ <false>
+ <xsl:value-of select="deep-equal(//comment()[1], //comment()[3])" />
+ </false>
+ </out>
+ </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