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 2023/12/31 17:19:54 UTC

(xalan-java) branch xalan-j_xslt3.0 updated: adding a working new test case for xsl:for-each-group instruction

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 bd574aaa adding a working new test case for xsl:for-each-group instruction
     new d8dfe26f Merge pull request #147 from mukulga/xalan-j_xslt3.0_mukul
bd574aaa is described below

commit bd574aaa9405c0b54d59ed3831bc4cdfcc7f3d57
Author: Mukul Gandhi <ga...@gmail.com>
AuthorDate: Sun Dec 31 22:45:34 2023 +0530

    adding a working new test case for xsl:for-each-group instruction
---
 src/org/apache/xpath/objects/XObject.java       |  5 ++++
 tests/grouping/gold/test30.out                  | 23 +++++++++++++++
 tests/grouping/test30.xml                       | 20 +++++++++++++
 tests/grouping/test30.xsl                       | 39 +++++++++++++++++++++++++
 tests/org/apache/xalan/xslt3/GroupingTests.java | 10 +++++++
 5 files changed, 97 insertions(+)

diff --git a/src/org/apache/xpath/objects/XObject.java b/src/org/apache/xpath/objects/XObject.java
index 3f986deb..4ff9de6b 100644
--- a/src/org/apache/xpath/objects/XObject.java
+++ b/src/org/apache/xpath/objects/XObject.java
@@ -1090,6 +1090,11 @@ public class XObject extends Expression implements Serializable, Cloneable
     else if ((this instanceof XSBoolean) && (obj2 instanceof XSBoolean)) {
        return ((XSBoolean)this).equals((XSBoolean)obj2);    
     }
+    else if ((this instanceof XBoolean) && (obj2 instanceof XBooleanStatic)) {
+       boolean lBool = ((XBoolean)this).bool();
+       boolean rBool = ((XBooleanStatic)obj2).bool();
+       return (lBool == rBool);
+    }
     else if ((this instanceof XSInteger) && (obj2 instanceof XSInteger)) {
        return ((XSInteger)this).equals((XSInteger)obj2);    
     }
diff --git a/tests/grouping/gold/test30.out b/tests/grouping/gold/test30.out
new file mode 100644
index 00000000..2827af90
--- /dev/null
+++ b/tests/grouping/gold/test30.out
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?><result>
+  <group groupingCriteria="1,3">
+    <a>
+    <itm1>hi</itm1>
+    <itm2>hello</itm2>
+    <itm3>there</itm3>
+  </a>
+    <b>
+    <itm1>this</itm1>
+    <itm2>is</itm2>
+    <itm3>nice</itm3>
+  </b>
+    <d>
+    <itm1>this is ok</itm1>
+  </d>
+  </group>
+  <group groupingCriteria="not(1,3)">
+    <c>
+    <itm1>hello</itm1>
+    <itm2>friends</itm2>
+  </c>
+  </group>
+</result>
diff --git a/tests/grouping/test30.xml b/tests/grouping/test30.xml
new file mode 100644
index 00000000..0bac50f5
--- /dev/null
+++ b/tests/grouping/test30.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <a>
+    <itm1>hi</itm1>
+    <itm2>hello</itm2>
+    <itm3>there</itm3>
+  </a>
+  <b>
+    <itm1>this</itm1>
+    <itm2>is</itm2>
+    <itm3>nice</itm3>
+  </b>
+  <c>
+    <itm1>hello</itm1>
+    <itm2>friends</itm2>
+  </c>
+  <d>
+    <itm1>this is ok</itm1>
+  </d>
+</root>
diff --git a/tests/grouping/test30.xsl b/tests/grouping/test30.xsl
new file mode 100644
index 00000000..84874b0d
--- /dev/null
+++ b/tests/grouping/test30.xsl
@@ -0,0 +1,39 @@
+<?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 test30.xml -->                
+  
+  <xsl:output method="xml" indent="yes"/>
+  
+  <xsl:template match="/root">
+     <result>
+       <xsl:for-each-group select="*" group-by="(count(*) eq 1) or (count(*) eq 3)">
+          <group groupingCriteria="{if (current-grouping-key() eq true()) then '1,3' else 'not(1,3)'}">
+            <xsl:copy-of select="current-group()"/>
+          </group>
+       </xsl:for-each-group>
+     </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/org/apache/xalan/xslt3/GroupingTests.java b/tests/org/apache/xalan/xslt3/GroupingTests.java
index d184703e..48c1d1b7 100644
--- a/tests/org/apache/xalan/xslt3/GroupingTests.java
+++ b/tests/org/apache/xalan/xslt3/GroupingTests.java
@@ -339,5 +339,15 @@ public class GroupingTests extends XslTransformTestsUtil {
         
         runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
     }
+    
+    @Test
+    public void xslGroupingTest30() {
+        String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test30.xml"; 
+        String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test30.xsl";
+        
+        String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test30.out";
+        
+        runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+    }
 
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xalan.apache.org
For additional commands, e-mail: commits-help@xalan.apache.org