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/06/08 10:31:01 UTC

(xalan-java) branch xalan-j_xslt3.0 updated: committing implementation of xpath3.1 function map:remove, and few related working new test cases. committing as well, minor improvements to comments within few previously commmited test case xsl stylesheets.

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 065dd83f committing implementation of xpath3.1 function map:remove, and few related working new test cases. committing as well, minor improvements to comments within few previously commmited test case xsl stylesheets.
065dd83f is described below

commit 065dd83f9bf23f082cbce8c9ae8f1b38379757e2
Author: Mukul Gandhi <ga...@gmail.com>
AuthorDate: Sat Jun 8 16:00:45 2024 +0530

    committing implementation of xpath3.1 function map:remove, and few related working new test cases. committing as well, minor improvements to comments within few previously commmited test case xsl stylesheets.
---
 src/org/apache/xpath/compiler/FunctionTable.java   |  11 +-
 src/org/apache/xpath/compiler/Keywords.java        |   3 +
 src/org/apache/xpath/compiler/XPathParserImpl.java |   3 +
 src/org/apache/xpath/composite/MapConstructor.java |   4 +
 .../apache/xpath/functions/map/FuncMapRemove.java  | 113 +++++++++++++++++++++
 src/org/apache/xpath/objects/XObject.java          |  10 +-
 tests/org/apache/xalan/xpath3/XPathMapTests.java   |  20 ++++
 tests/xpath_maps/gold/test21.out                   |  56 ++++++++++
 tests/xpath_maps/gold/test22.out                   |  30 ++++++
 tests/xpath_maps/test1.xsl                         |   9 +-
 tests/xpath_maps/test10.xsl                        |   8 +-
 tests/xpath_maps/test11.xsl                        |   8 +-
 tests/xpath_maps/test12.xsl                        |   8 +-
 tests/xpath_maps/test13.xsl                        |   6 +-
 tests/xpath_maps/test14.xsl                        |   6 +-
 tests/xpath_maps/test15.xsl                        |   6 +-
 tests/xpath_maps/test16.xsl                        |   4 +-
 tests/xpath_maps/test17.xsl                        |   4 +-
 tests/xpath_maps/test18.xsl                        |   6 +-
 tests/xpath_maps/test19.xsl                        |   8 +-
 tests/xpath_maps/test2.xsl                         |   7 +-
 tests/xpath_maps/test20.xsl                        |   6 +-
 tests/xpath_maps/test21.xsl                        |  67 ++++++++++++
 tests/xpath_maps/{test10.xsl => test22.xsl}        |  36 ++++---
 tests/xpath_maps/test3.xsl                         |   7 +-
 tests/xpath_maps/test4.xsl                         |   7 +-
 tests/xpath_maps/test5.xsl                         |   9 +-
 tests/xpath_maps/test6.xsl                         |   7 +-
 tests/xpath_maps/test7.xsl                         |   8 +-
 tests/xpath_maps/test8.xsl                         |   7 +-
 tests/xpath_maps/test9.xsl                         |  11 +-
 31 files changed, 405 insertions(+), 90 deletions(-)

diff --git a/src/org/apache/xpath/compiler/FunctionTable.java b/src/org/apache/xpath/compiler/FunctionTable.java
index ae9dcbec..4f2cabfc 100644
--- a/src/org/apache/xpath/compiler/FunctionTable.java
+++ b/src/org/apache/xpath/compiler/FunctionTable.java
@@ -498,6 +498,9 @@ public class FunctionTable
   
   /** The 'array:fold-right()' id. */
   public static final int FUNC_ARRAY_FOLD_RIGHT = 158;
+  
+  /** The 'map:remove()' id. */
+  public static final int FUNC_MAP_REMOVE = 159;
 
   // Proprietary
 
@@ -544,7 +547,8 @@ public class FunctionTable
   static final Integer[] XPATH_MAP_FUNC_IDS = new Integer[] { new Integer(FUNC_MAP_MERGE), new Integer(FUNC_MAP_SIZE), 
 		                                                      new Integer(FUNC_MAP_KEYS), new Integer(FUNC_MAP_CONTAINS), 
 		                                                      new Integer(FUNC_MAP_GET), new Integer(FUNC_MAP_PUT), 
-		                                                      new Integer(FUNC_MAP_ENTRY), new Integer(FUNC_MAP_FOREACH) };
+		                                                      new Integer(FUNC_MAP_ENTRY), new Integer(FUNC_MAP_FOREACH),
+		                                                      new Integer(FUNC_MAP_REMOVE) };
   
   static final List<Integer> XPATH_MAP_FUNC_IDS_ARR = Arrays.asList(XPATH_MAP_FUNC_IDS);
   
@@ -589,7 +593,7 @@ public class FunctionTable
    * Number of built in functions. Be sure to update this as
    * built-in functions are added.
    */
-  private static final int NUM_BUILT_IN_FUNCS = 159;
+  private static final int NUM_BUILT_IN_FUNCS = 160;
 
   /**
    * Number of built-in functions that may be added.
@@ -837,6 +841,7 @@ public class FunctionTable
     m_functions[FUNC_MAP_PUT] = org.apache.xpath.functions.map.FuncMapPut.class;
     m_functions[FUNC_MAP_ENTRY] = org.apache.xpath.functions.map.FuncMapEntry.class;
     m_functions[FUNC_MAP_FOREACH] = org.apache.xpath.functions.map.FuncMapForEach.class;
+    m_functions[FUNC_MAP_REMOVE] = org.apache.xpath.functions.map.FuncMapRemove.class;
     
     // XPath 3.1 built-in functions configurations for the array 
     // functions namespace http://www.w3.org/2005/xpath-functions/array    
@@ -1136,6 +1141,8 @@ public class FunctionTable
                          new Integer(FunctionTable.FUNC_MAP_ENTRY));
          m_functionID.put(Keywords.FUNC_MAP_FOREACH,
                          new Integer(FunctionTable.FUNC_MAP_FOREACH));
+         m_functionID.put(Keywords.FUNC_MAP_REMOVE,
+                         new Integer(FunctionTable.FUNC_MAP_REMOVE));
          
          // XPath 3.1 functions configurations for the array functions 
          // namespace http://www.w3.org/2005/xpath-functions/array
diff --git a/src/org/apache/xpath/compiler/Keywords.java b/src/org/apache/xpath/compiler/Keywords.java
index c371f10a..bd1a68de 100644
--- a/src/org/apache/xpath/compiler/Keywords.java
+++ b/src/org/apache/xpath/compiler/Keywords.java
@@ -597,6 +597,9 @@ public class Keywords
   /** map:for-each function string. */
   public static final String FUNC_MAP_FOREACH = "for-each";
   
+  /** map:remove function string. */
+  public static final String FUNC_MAP_REMOVE = "remove";
+  
   /** parse-json function string. */
   public static final String FUNC_PARSE_JSON = "parse-json";
   
diff --git a/src/org/apache/xpath/compiler/XPathParserImpl.java b/src/org/apache/xpath/compiler/XPathParserImpl.java
index 2bbdb2ba..df9f39bd 100644
--- a/src/org/apache/xpath/compiler/XPathParserImpl.java
+++ b/src/org/apache/xpath/compiler/XPathParserImpl.java
@@ -1151,6 +1151,9 @@ public class XPathParserImpl
 		      case "entry":
 			     id = FunctionTable.FUNC_MAP_ENTRY;
 			     break;
+		      case "remove":
+				 id = FunctionTable.FUNC_MAP_REMOVE;
+				 break;
 		      case "for-each":
 			     id = FunctionTable.FUNC_MAP_FOREACH;
 			     break;
diff --git a/src/org/apache/xpath/composite/MapConstructor.java b/src/org/apache/xpath/composite/MapConstructor.java
index 40614da8..d36c51c6 100644
--- a/src/org/apache/xpath/composite/MapConstructor.java
+++ b/src/org/apache/xpath/composite/MapConstructor.java
@@ -47,6 +47,7 @@ import org.apache.xpath.objects.XPathArray;
 import org.apache.xpath.objects.XPathMap;
 import org.apache.xpath.objects.XString;
 
+import xml.xpath31.processor.types.XSDouble;
 import xml.xpath31.processor.types.XSNumericType;
 import xml.xpath31.processor.types.XSString;
 
@@ -107,6 +108,9 @@ public class MapConstructor extends Expression {
            if (mapEntryKey instanceof XString) {
         	  mapEntryKey = new XSString(((XString)mapEntryKey).str()); 
            }
+           else if (mapEntryKey instanceof XNumber) {
+        	  mapEntryKey = new XSDouble(((XNumber)mapEntryKey).num());  
+           }
            
            if (prefixTable != null) {
         	  xpathValueStr = XslTransformEvaluationHelper.replaceNsUrisWithPrefixesOnXPathStr(xpathValueStr, 
diff --git a/src/org/apache/xpath/functions/map/FuncMapRemove.java b/src/org/apache/xpath/functions/map/FuncMapRemove.java
new file mode 100644
index 00000000..4a5571cb
--- /dev/null
+++ b/src/org/apache/xpath/functions/map/FuncMapRemove.java
@@ -0,0 +1,113 @@
+/*
+ * 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.xpath.functions.map;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.transform.SourceLocator;
+
+import org.apache.xalan.xslt.util.XslTransformEvaluationHelper;
+import org.apache.xpath.Expression;
+import org.apache.xpath.XPathCollationSupport;
+import org.apache.xpath.XPathContext;
+import org.apache.xpath.functions.Function2Args;
+import org.apache.xpath.objects.ResultSequence;
+import org.apache.xpath.objects.XObject;
+import org.apache.xpath.objects.XPathMap;
+import org.apache.xpath.operations.Variable;
+
+/**
+ * Implementation of an XPath 3.1 function, map:remove.
+ * 
+ * @author Mukul Gandhi <mu...@apache.org>
+ * 
+ * @xsl.usage advanced
+ */
+public class FuncMapRemove extends Function2Args {
+
+	private static final long serialVersionUID = 85207005600072930L;
+
+	public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException {
+		
+		XObject result = null;
+		
+		SourceLocator srcLocator = xctxt.getSAXLocator();
+	       
+	    Expression arg0 = getArg0();
+	    Expression arg1 = getArg1();
+	    
+	    XPathMap arg0Map = null;
+	    
+	    if (arg0 instanceof Variable) {
+	       XObject arg0Obj = ((Variable)arg0).execute(xctxt);
+	       if (arg0Obj instanceof XPathMap) {
+	    	  arg0Map = (XPathMap)arg0Obj;   
+	       }
+	       else {
+	    	  throw new javax.xml.transform.TransformerException("XPTY0004 : The 1st argument provided to function call "
+                                                                        + "map:remove is not an xdm map, or cannot be cast to an xdm map.", srcLocator);  
+	       }
+	    }
+	    else {
+	       XObject arg0Obj = arg0.execute(xctxt);
+	       if (arg0Obj instanceof XPathMap) {
+		      arg0Map = (XPathMap)arg0Obj;   
+		   }
+		   else {
+			  throw new javax.xml.transform.TransformerException("XPTY0004 : The 1st argument provided to function call "
+                                                                        + "map:remove is not an xdm map, or cannot be cast to an xdm map.", srcLocator);   
+		   }
+	    }	    	    
+	    	    
+	    XObject arg1Obj = null;
+	    ResultSequence inpSeq1 = null;
+	    if (arg1 instanceof Variable) {
+	    	arg1Obj = ((Variable)arg1).execute(xctxt);
+	    	inpSeq1 = XslTransformEvaluationHelper.getResultSequenceFromXObject(arg1Obj, xctxt);
+	    } 
+	    else {
+	    	arg1Obj = arg1.execute(xctxt);
+	    	inpSeq1 = XslTransformEvaluationHelper.getResultSequenceFromXObject(arg1Obj, xctxt);
+	    }
+	    
+	    Map<XObject, XObject> nativeResultMap = new HashMap<XObject, XObject>();
+	    
+	    Map<XObject, XObject> nativeMap = arg0Map.getNativeMap();
+	    Set<XObject> keysInMap = nativeMap.keySet();
+	    Iterator<XObject> iter = keysInMap.iterator();	    
+	    String xpathDefaultCollation = xctxt.getDefaultCollation();
+	    XPathCollationSupport xpathCollationSupport = xctxt.getXPathCollationSupport();
+	    while (iter.hasNext()) {
+	    	XObject key = iter.next();
+	    	if (!XslTransformEvaluationHelper.contains(inpSeq1, key, xpathDefaultCollation, xpathCollationSupport)) {
+	    	   XObject value = nativeMap.get(key);
+	    	   nativeResultMap.put(key, value);
+	    	}
+	    }
+	    
+	    XPathMap resultMap = new XPathMap();
+	    resultMap.setNativeMap(nativeResultMap);
+	    
+	    result = resultMap;
+	    
+	    return result;
+	}
+
+}
diff --git a/src/org/apache/xpath/objects/XObject.java b/src/org/apache/xpath/objects/XObject.java
index d542924c..410a97f5 100644
--- a/src/org/apache/xpath/objects/XObject.java
+++ b/src/org/apache/xpath/objects/XObject.java
@@ -41,6 +41,7 @@ import org.w3c.dom.DocumentFragment;
 import org.w3c.dom.NodeList;
 import org.w3c.dom.traversal.NodeIterator;
 
+import xml.xpath31.processor.types.XSAnySimpleType;
 import xml.xpath31.processor.types.XSAnyURI;
 import xml.xpath31.processor.types.XSBoolean;
 import xml.xpath31.processor.types.XSDate;
@@ -1176,7 +1177,14 @@ public class XObject extends Expression implements Serializable, Cloneable
   }
   
   public int hashCode() {
-	 String strVal = this.str();
+	 String strVal = null;
+	 
+	 if (this instanceof XSAnySimpleType) {
+		strVal = ((XSAnySimpleType)this).stringValue();
+	 }
+	 else {
+		strVal = this.str(); 
+	 }
 	 
 	 return strVal.hashCode();
   }
diff --git a/tests/org/apache/xalan/xpath3/XPathMapTests.java b/tests/org/apache/xalan/xpath3/XPathMapTests.java
index 385bb3d3..53baaedb 100644
--- a/tests/org/apache/xalan/xpath3/XPathMapTests.java
+++ b/tests/org/apache/xalan/xpath3/XPathMapTests.java
@@ -247,5 +247,25 @@ public class XPathMapTests extends XSLTransformTestsUtil {
         
         runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
     }
+    
+    @Test
+    public void xslMapTest21() {
+        String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test21.xsl"; 
+        String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test21.xsl";
+        
+        String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test21.out";                
+        
+        runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+    }
+    
+    @Test
+    public void xslMapTest22() {
+        String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test22.xsl"; 
+        String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test22.xsl";
+        
+        String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test22.out";                
+        
+        runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+    }
 
 }
diff --git a/tests/xpath_maps/gold/test21.out b/tests/xpath_maps/gold/test21.out
new file mode 100644
index 00000000..e4f25ab6
--- /dev/null
+++ b/tests/xpath_maps/gold/test21.out
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?><result>
+  <one>true</one>
+  <two>true</two>
+  <map size="5">
+    <entry>
+      <key>1</key>
+      <value>Montag</value>
+    </entry>
+    <entry>
+      <key>2</key>
+      <value>Dienstag</value>
+    </entry>
+    <entry>
+      <key>3</key>
+      <value>Mittwoch</value>
+    </entry>
+    <entry>
+      <key>4</key>
+      <value>Donnerstag</value>
+    </entry>
+    <entry>
+      <key>5</key>
+      <value>Freitag</value>
+    </entry>
+  </map>
+  <map size="7">
+    <entry>
+      <key>0</key>
+      <value>Sonntag</value>
+    </entry>
+    <entry>
+      <key>1</key>
+      <value>Montag</value>
+    </entry>
+    <entry>
+      <key>2</key>
+      <value>Dienstag</value>
+    </entry>
+    <entry>
+      <key>3</key>
+      <value>Mittwoch</value>
+    </entry>
+    <entry>
+      <key>4</key>
+      <value>Donnerstag</value>
+    </entry>
+    <entry>
+      <key>5</key>
+      <value>Freitag</value>
+    </entry>
+    <entry>
+      <key>6</key>
+      <value>Samstag</value>
+    </entry>
+  </map>
+</result>
diff --git a/tests/xpath_maps/gold/test22.out b/tests/xpath_maps/gold/test22.out
new file mode 100644
index 00000000..c4427331
--- /dev/null
+++ b/tests/xpath_maps/gold/test22.out
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?><map>
+  <entry>
+    <key>0</key>
+    <value>Sonntag</value>
+  </entry>
+  <entry>
+    <key>1</key>
+    <value>Montag</value>
+  </entry>
+  <entry>
+    <key>2</key>
+    <value>Dienstag</value>
+  </entry>
+  <entry>
+    <key>3</key>
+    <value>Mittwoch</value>
+  </entry>
+  <entry>
+    <key>4</key>
+    <value>Donnerstag</value>
+  </entry>
+  <entry>
+    <key>5</key>
+    <value>Freitag</value>
+  </entry>
+  <entry>
+    <key>6</key>
+    <value>Samstag</value>
+  </entry>
+</map>
diff --git a/tests/xpath_maps/test1.xsl b/tests/xpath_maps/test1.xsl
index dfb2f197..5d37905d 100644
--- a/tests/xpath_maps/test1.xsl
+++ b/tests/xpath_maps/test1.xsl
@@ -3,11 +3,11 @@
                 version="3.0">
                 
    <!-- Author: mukulg@apache.org -->                
-
-   <xsl:output method="text"/>
    
    <!-- An XPath 3.1 test case, to test an XPath 'map' 
-        expression. -->   
+        expression. -->
+        
+   <xsl:output method="text"/>          
 
    <xsl:template match="/">
       <xsl:variable name="map1" select="map {
@@ -19,7 +19,8 @@
 			  'Fr' : 'Friday',
 			  'Sa' : 'Saturday'}"/>
 			  
-	  <!-- map lookup using function call syntax -->
+	  <!-- The XPath expression used below, does map value lookup 
+	       using function call syntax. -->
 	  <xsl:value-of select="$map1('Su')"/>
    </xsl:template>
    
diff --git a/tests/xpath_maps/test10.xsl b/tests/xpath_maps/test10.xsl
index dfdea04a..771d936c 100644
--- a/tests/xpath_maps/test10.xsl
+++ b/tests/xpath_maps/test10.xsl
@@ -6,11 +6,11 @@
                 version="3.0">
                 
    <!-- Author: mukulg@apache.org -->                 				
-
-   <xsl:output method="xml" indent="yes"/>
    
-   <!-- An XPath 3.1 test case, to test map constructor expression
-        and the associated map functions. -->
+   <!-- An XSLT test case to test, XPath 3.1 map constructor expression
+        and function map:keys. -->
+        
+   <xsl:output method="xml" indent="yes"/>        
 
    <xsl:template match="/">
 	  <xsl:variable name="map1" select="map {'true' : xs:boolean(1), 'false' : xs:boolean(0)}"/>
diff --git a/tests/xpath_maps/test11.xsl b/tests/xpath_maps/test11.xsl
index f938577a..4f2f152f 100644
--- a/tests/xpath_maps/test11.xsl
+++ b/tests/xpath_maps/test11.xsl
@@ -5,12 +5,12 @@
 				exclude-result-prefixes="xs map"
                 version="3.0">				
 
-   <!-- Author: mukulg@apache.org -->                 				
+   <!-- Author: mukulg@apache.org -->
+   
+   <!-- An XSLT test case to test, XPath 3.1 SequenceType MapTest specified as 
+        value of xsl:variable's "as" attribute. -->            				
 
    <xsl:output method="xml" indent="yes"/>
-   
-   <!-- An XPath 3.1 test case, to test SequenceType MapTest specified as 
-        value of xsl:variable's "as" attribute. -->
 
    <xsl:template match="/">
 	  <xsl:variable name="map1" select="map {'true' : xs:boolean(1), 'false' : xs:boolean(0)}" as="map(*)"/>
diff --git a/tests/xpath_maps/test12.xsl b/tests/xpath_maps/test12.xsl
index 906a095e..8ef3e4f2 100644
--- a/tests/xpath_maps/test12.xsl
+++ b/tests/xpath_maps/test12.xsl
@@ -5,12 +5,12 @@
 				exclude-result-prefixes="xs map"
                 version="3.0">				
 
-   <!-- Author: mukulg@apache.org -->                 				
+   <!-- Author: mukulg@apache.org -->
+   
+   <!-- An XSLT test case to test, XPath 3.1 SequenceType MapTest specified as 
+        value of xsl:variable's "as" attribute. -->            				
 
    <xsl:output method="xml" indent="yes"/>
-   
-   <!-- An XPath 3.1 test case, to test SequenceType MapTest specified as 
-        value of xsl:variable's "as" attribute. -->
 
    <xsl:template match="/">	  
       <result>
diff --git a/tests/xpath_maps/test13.xsl b/tests/xpath_maps/test13.xsl
index da0cf1b3..3916eaad 100644
--- a/tests/xpath_maps/test13.xsl
+++ b/tests/xpath_maps/test13.xsl
@@ -6,10 +6,10 @@
                 version="3.0">				
 
    <!-- Author: mukulg@apache.org -->                 				
-
-   <xsl:output method="xml" indent="yes"/>
    
-   <!-- An XPath 3.1 test case, to test maps and arrays. -->
+   <!-- An XSLT test case to test, XPath 3.1 maps and arrays. -->
+   
+   <xsl:output method="xml" indent="yes"/>
 
    <xsl:template match="/">	  
       <result>
diff --git a/tests/xpath_maps/test14.xsl b/tests/xpath_maps/test14.xsl
index da0cf1b3..3916eaad 100644
--- a/tests/xpath_maps/test14.xsl
+++ b/tests/xpath_maps/test14.xsl
@@ -6,10 +6,10 @@
                 version="3.0">				
 
    <!-- Author: mukulg@apache.org -->                 				
-
-   <xsl:output method="xml" indent="yes"/>
    
-   <!-- An XPath 3.1 test case, to test maps and arrays. -->
+   <!-- An XSLT test case to test, XPath 3.1 maps and arrays. -->
+   
+   <xsl:output method="xml" indent="yes"/>
 
    <xsl:template match="/">	  
       <result>
diff --git a/tests/xpath_maps/test15.xsl b/tests/xpath_maps/test15.xsl
index 240b0c45..64e2ee25 100644
--- a/tests/xpath_maps/test15.xsl
+++ b/tests/xpath_maps/test15.xsl
@@ -6,10 +6,10 @@
                 version="3.0">
                 
    <!-- Author: mukulg@apache.org -->                 
-				
-   <xsl:output method="xml" indent="yes"/>
    
-   <!-- An XSLT test case, to test XPath 3.1 function map:for-each. --> 
+   <!-- An XSLT test case, to test XPath 3.1 function map:for-each. -->
+   
+   <xsl:output method="xml" indent="yes"/> 
   
    <xsl:template match="/">
      <result>
diff --git a/tests/xpath_maps/test16.xsl b/tests/xpath_maps/test16.xsl
index c84edc84..110bad2d 100644
--- a/tests/xpath_maps/test16.xsl
+++ b/tests/xpath_maps/test16.xsl
@@ -6,10 +6,10 @@
                 version="3.0">
 				
    <!-- Author: mukulg@apache.org -->                 
-				
-   <xsl:output method="xml" indent="yes"/>
    
    <!-- An XSLT test case, to test XPath 3.1 function map:for-each. -->
+   
+   <xsl:output method="xml" indent="yes"/>
   
    <xsl:template match="/">
      <result>
diff --git a/tests/xpath_maps/test17.xsl b/tests/xpath_maps/test17.xsl
index 54c09a09..0b3196f4 100644
--- a/tests/xpath_maps/test17.xsl
+++ b/tests/xpath_maps/test17.xsl
@@ -7,10 +7,10 @@
                 version="3.0">
 				
    <!-- Author: mukulg@apache.org -->                 
-				
-   <xsl:output method="xml" indent="yes"/>
    
    <!-- An XSLT test case, to test XPath 3.1 function map:for-each. -->
+   
+   <xsl:output method="xml" indent="yes"/>
   
    <xsl:template match="/">
      <result>
diff --git a/tests/xpath_maps/test18.xsl b/tests/xpath_maps/test18.xsl
index 66fe3a5b..068501e2 100644
--- a/tests/xpath_maps/test18.xsl
+++ b/tests/xpath_maps/test18.xsl
@@ -7,10 +7,10 @@
                 version="3.0">
                 
    <!-- Author: mukulg@apache.org -->                 
-				
-   <xsl:output method="xml" indent="yes"/>
    
-   <!-- An XSLT test case, to test XPath 3.1 function map:for-each. --> 
+   <!-- An XSLT test case, to test XPath 3.1 function map:for-each. -->
+   
+   <xsl:output method="xml" indent="yes"/>
   
    <xsl:template match="/">
      <result>
diff --git a/tests/xpath_maps/test19.xsl b/tests/xpath_maps/test19.xsl
index c37c3691..ea334863 100644
--- a/tests/xpath_maps/test19.xsl
+++ b/tests/xpath_maps/test19.xsl
@@ -5,11 +5,11 @@
 				exclude-result-prefixes="xs map"
                 version="3.0">
                 
-   <!-- Author: mukulg@apache.org -->                 
-				
-   <xsl:output method="xml" indent="yes"/>
+   <!-- Author: mukulg@apache.org -->                 				   
    
-   <!-- An XSLT test case, to test XPath 3.1 function map:for-each. --> 
+   <!-- An XSLT test case, to test XPath 3.1 function map:for-each. -->
+   
+   <xsl:output method="xml" indent="yes"/> 
   
    <xsl:template match="/">
      <result>
diff --git a/tests/xpath_maps/test2.xsl b/tests/xpath_maps/test2.xsl
index 278ac963..095fcb83 100644
--- a/tests/xpath_maps/test2.xsl
+++ b/tests/xpath_maps/test2.xsl
@@ -5,11 +5,10 @@
                 version="3.0">				
 
    <!-- Author: mukulg@apache.org -->                
-
-   <xsl:output method="xml" indent="yes"/>
    
-   <!-- An XPath 3.1 test case, to test an XPath map:size 
-        function. -->
+   <!-- An XPath 3.1 test case, to test an XPath function map:size. -->
+        
+   <xsl:output method="xml" indent="yes"/>        
 
    <xsl:template match="/">
       <xsl:variable name="map1" select="map {
diff --git a/tests/xpath_maps/test20.xsl b/tests/xpath_maps/test20.xsl
index 75d57586..df7f08c4 100644
--- a/tests/xpath_maps/test20.xsl
+++ b/tests/xpath_maps/test20.xsl
@@ -5,11 +5,11 @@
 				exclude-result-prefixes="xs map"
                 version="3.0">
 				
-   <!-- Author: mukulg@apache.org -->                 
+   <!-- Author: mukulg@apache.org -->
+   
+   <!-- An XSLT test case, to test XPath 3.1 function map:for-each. -->                
 				
    <xsl:output method="xml" indent="yes"/>
-   
-   <!-- An XSLT test case, to test XPath 3.1 function map:for-each. -->
   
    <xsl:template match="/">
      <result>
diff --git a/tests/xpath_maps/test21.xsl b/tests/xpath_maps/test21.xsl
new file mode 100644
index 00000000..1e244bc3
--- /dev/null
+++ b/tests/xpath_maps/test21.xsl
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                xmlns:map="http://www.w3.org/2005/xpath-functions/map"
+				exclude-result-prefixes="map"
+                version="3.0">
+                
+   <!-- Author: mukulg@apache.org -->
+    
+   <!-- An XSLT test case, to test XPath 3.1 function map:remove. -->              
+				
+   <xsl:output method="xml" indent="yes"/>                                                 
+
+    <xsl:output method="xml" indent="yes"/>
+
+    <xsl:template match="/">
+	   <xsl:variable name="map1" select="map{0 : 'Sonntag', 1 : 'Montag', 2 : 'Dienstag', 3 : 
+	                                        'Mittwoch', 4 : 'Donnerstag', 5 : 'Freitag', 6 : 'Samstag'}"/>	   
+	   <result>
+	      <xsl:variable name="mapAfterRemove1" select="map:remove($map1,4)"/>
+		  <one>
+			 <xsl:value-of select="(map:contains($mapAfterRemove1,4) eq false()) and (map:size($mapAfterRemove1) eq 6)"/>
+		  </one>
+		  <xsl:variable name="mapAfterRemove2" select="map:remove($map1,23)"/>
+		  <two>
+			 <xsl:value-of select="map:size($mapAfterRemove2) eq 7"/>
+		  </two>
+		  <xsl:variable name="keysToBeRemoved" select="(0, 6 to 7)"/>
+		  <xsl:variable name="mapAfterRemove3" select="map:remove($map1,$keysToBeRemoved)"/>
+		  <map size="{map:size($mapAfterRemove3)}">
+			<xsl:for-each select="sort(map:keys($mapAfterRemove3))">
+			  <entry>
+				<key><xsl:value-of select="."/></key>
+				<value><xsl:value-of select="map:get($mapAfterRemove3, .)"/></value>
+		      </entry>
+			</xsl:for-each>
+		  </map>
+		  <xsl:variable name="mapAfterRemove4" select="map:remove($map1,())"/>
+		  <map size="{map:size($mapAfterRemove4)}">
+			<xsl:for-each select="sort(map:keys($mapAfterRemove4))">
+			  <entry>
+				<key><xsl:value-of select="."/></key>
+				<value><xsl:value-of select="map:get($mapAfterRemove4, .)"/></value>
+		      </entry>
+			</xsl:for-each>
+		  </map>
+	   </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>
diff --git a/tests/xpath_maps/test10.xsl b/tests/xpath_maps/test22.xsl
similarity index 60%
copy from tests/xpath_maps/test10.xsl
copy to tests/xpath_maps/test22.xsl
index dfdea04a..ea44ca79 100644
--- a/tests/xpath_maps/test10.xsl
+++ b/tests/xpath_maps/test22.xsl
@@ -1,25 +1,29 @@
 <?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:map="http://www.w3.org/2005/xpath-functions/map"
-				exclude-result-prefixes="xs map"
+				exclude-result-prefixes="map"
                 version="3.0">
                 
-   <!-- Author: mukulg@apache.org -->                 				
+    <!-- Author: mukulg@apache.org -->
+    
+    <!-- An XSLT test case, to test XPath 3.1 maps and function map:get. -->                                            
 
-   <xsl:output method="xml" indent="yes"/>
-   
-   <!-- An XPath 3.1 test case, to test map constructor expression
-        and the associated map functions. -->
+    <xsl:output method="xml" indent="yes"/>
 
-   <xsl:template match="/">
-	  <xsl:variable name="map1" select="map {'true' : xs:boolean(1), 'false' : xs:boolean(0)}"/>
-      <result>
-         <xsl:value-of select="count(map:keys($map1))"/>   
-	  </result>
-   </xsl:template>
-   
-   <!--
+    <xsl:template match="/">
+	   <xsl:variable name="map1" select="map{0 : 'Sonntag', 1 : 'Montag', 2 : 'Dienstag', 3 : 
+	                                        'Mittwoch', 4 : 'Donnerstag', 5 : 'Freitag', 6 : 'Samstag'}"/>	   
+	   <map>	     
+		 <xsl:for-each select="0 to 6">
+		   <entry>
+			 <key><xsl:value-of select="."/></key>
+			 <value><xsl:value-of select="map:get($map1, .)"/></value>
+		   </entry>
+		 </xsl:for-each>
+	   </map>
+    </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
@@ -36,5 +40,5 @@
       * See the License for the specific language governing permissions and
       * limitations under the License.
    -->
-
+    
 </xsl:stylesheet>
diff --git a/tests/xpath_maps/test3.xsl b/tests/xpath_maps/test3.xsl
index e09017b8..0cadbf3d 100644
--- a/tests/xpath_maps/test3.xsl
+++ b/tests/xpath_maps/test3.xsl
@@ -5,11 +5,10 @@
                 version="3.0">				
 
    <!-- Author: mukulg@apache.org -->                
-
-   <xsl:output method="xml" indent="yes"/>
    
-   <!-- An XPath 3.1 test case, to test an XPath map:keys 
-        function. -->
+   <!-- An XPath 3.1 test case, to test an XPath function map:keys. -->
+        
+   <xsl:output method="xml" indent="yes"/>        
 
    <xsl:template match="/">
       <xsl:variable name="map1" select="map {
diff --git a/tests/xpath_maps/test4.xsl b/tests/xpath_maps/test4.xsl
index 47977069..c352c342 100644
--- a/tests/xpath_maps/test4.xsl
+++ b/tests/xpath_maps/test4.xsl
@@ -5,11 +5,10 @@
                 version="3.0">				
 
    <!-- Author: mukulg@apache.org -->                
-
-   <xsl:output method="xml" indent="yes"/>
    
-   <!-- An XPath 3.1 test case, to test an XPath map:contains 
-        function. -->
+   <!-- An XPath 3.1 test case, to test an XPath function map:contains. -->
+        
+   <xsl:output method="xml" indent="yes"/>        
 
    <xsl:template match="/">
       <xsl:variable name="map1" select="map{ 0 : 'Sonntag', 1 : 'Montag', 2 : 'Dienstag',
diff --git a/tests/xpath_maps/test5.xsl b/tests/xpath_maps/test5.xsl
index 798b74f2..c26c69f6 100644
--- a/tests/xpath_maps/test5.xsl
+++ b/tests/xpath_maps/test5.xsl
@@ -4,12 +4,11 @@
 				exclude-result-prefixes="map"
                 version="3.0">				
 
-   <!-- Author: mukulg@apache.org -->                
-
-   <xsl:output method="xml" indent="yes"/>
+   <!-- Author: mukulg@apache.org -->                   
    
-   <!-- An XPath 3.1 test case, to test an XPath map:get 
-        function. -->
+   <!-- An XPath 3.1 test case, to test an XPath function map:get. -->
+        
+   <xsl:output method="xml" indent="yes"/>        
 
    <xsl:template match="/">
       <xsl:variable name="map1" select="map{ 0 : 'Sonntag', 1 : 'Montag', 2 : 'Dienstag',
diff --git a/tests/xpath_maps/test6.xsl b/tests/xpath_maps/test6.xsl
index 3baa00ab..028a1fa8 100644
--- a/tests/xpath_maps/test6.xsl
+++ b/tests/xpath_maps/test6.xsl
@@ -5,11 +5,10 @@
                 version="3.0">				
 
    <!-- Author: mukulg@apache.org -->                
-
-   <xsl:output method="xml" indent="yes"/>
    
-   <!-- An XPath 3.1 test case, to test an XPath map:put 
-        function. -->
+   <!-- An XPath 3.1 test case, to test an XPath function map:put. -->
+        
+   <xsl:output method="xml" indent="yes"/>        
 
    <xsl:template match="/">
       <xsl:variable name="map1" select="map{ 0 : 'Sonntag', 1 : 'Montag', 2 : 'Dienstag',
diff --git a/tests/xpath_maps/test7.xsl b/tests/xpath_maps/test7.xsl
index 90860ba0..40240e0a 100644
--- a/tests/xpath_maps/test7.xsl
+++ b/tests/xpath_maps/test7.xsl
@@ -5,11 +5,11 @@
                 version="3.0">				
 
    <!-- Author: mukulg@apache.org -->                
-
-   <xsl:output method="xml" indent="yes"/>
    
-   <!-- An XPath 3.1 test case, to test an XPath map:entry 
-        function. -->
+   <!-- An XPath 3.1 test case, to test XPath functions map:entry, 
+        map:get. -->
+        
+  <xsl:output method="xml" indent="yes"/>
 
    <xsl:template match="/">
       <result>
diff --git a/tests/xpath_maps/test8.xsl b/tests/xpath_maps/test8.xsl
index 265d7359..0accf999 100644
--- a/tests/xpath_maps/test8.xsl
+++ b/tests/xpath_maps/test8.xsl
@@ -6,10 +6,11 @@
                 version="3.0">
                 
    <!-- Author: mukulg@apache.org -->                
-
-   <xsl:output method="xml" indent="yes"/>
    
-   <!-- An XPath 3.1 test case, to test nesting of arrays and maps within another map. -->                			
+   <!-- An XSLT test case to test, XPath 3.1 map constructor expression
+        that nests other maps and arrays. -->
+   
+   <xsl:output method="xml" indent="yes"/>                			
 
    <xsl:output method="xml" indent="yes"/>
 
diff --git a/tests/xpath_maps/test9.xsl b/tests/xpath_maps/test9.xsl
index b1ffa31f..c70e8adc 100644
--- a/tests/xpath_maps/test9.xsl
+++ b/tests/xpath_maps/test9.xsl
@@ -4,11 +4,14 @@
 				exclude-result-prefixes="map"
                 version="3.0">
                 
-   <!-- Author: mukulg@apache.org -->                  			
-
-   <xsl:output method="xml" indent="yes"/>
+   <!-- Author: mukulg@apache.org -->                  			                 				
    
-   <!-- An XPath 3.1 test case, to test nesting of arrays and maps within another map. -->
+   <!-- An XSLT test case to test, XPath 3.1 map constructor expression
+        that nests another map. -->
+        
+   <xsl:output method="xml" indent="yes"/> 
+   
+   <xsl:output method="xml" indent="yes"/>
 
    <xsl:template match="/">
 	  <xsl:variable name="map1" select="map {


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