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/05/20 06:24:21 UTC

(xalan-java) branch xalan-j_xslt3.0 updated: implementing xath3.1 empty map expressions. implementing xpath3.1 functions map:contains, map:entry, map:get, map:keys, map:put, size. few other minor improvements and refactoring as well. committing few new relevant working xsl test cases as well

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 2b4772aa implementing xath3.1 empty map expressions. implementing xpath3.1 functions map:contains, map:entry, map:get, map:keys, map:put, size. few other minor improvements and refactoring as well. committing few new relevant working xsl test cases as well
2b4772aa is described below

commit 2b4772aa6cff7aba365937e4f90a050318e94df3
Author: Mukul Gandhi <ga...@gmail.com>
AuthorDate: Mon May 20 11:54:09 2024 +0530

    implementing xath3.1 empty map expressions. implementing xpath3.1 functions map:contains, map:entry, map:get, map:keys, map:put, size. few other minor improvements and refactoring as well. committing few new relevant working xsl test cases as well
---
 src/org/apache/xpath/compiler/FunctionTable.java   |  66 ++++++++-
 src/org/apache/xpath/compiler/Keywords.java        |  18 +++
 src/org/apache/xpath/compiler/Lexer.java           |   8 +-
 src/org/apache/xpath/compiler/XPathParserImpl.java | 155 +++++++++++++++------
 .../xpath/functions/map/FuncMapContains.java       |  76 ++++++++++
 .../apache/xpath/functions/map/FuncMapEntry.java   |  73 ++++++++++
 src/org/apache/xpath/functions/map/FuncMapGet.java |  77 ++++++++++
 .../apache/xpath/functions/map/FuncMapKeys.java    |  78 +++++++++++
 src/org/apache/xpath/functions/map/FuncMapPut.java |  94 +++++++++++++
 .../apache/xpath/functions/map/FuncMapSize.java    |  63 +++++++++
 src/org/apache/xpath/objects/XObject.java          |  22 +++
 src/org/apache/xpath/objects/XPathMap.java         |  15 +-
 tests/org/apache/xalan/xpath3/XPathMapTests.java   |  63 ++++++++-
 tests/xpath_maps/gold/test2.out                    |  11 ++
 tests/xpath_maps/gold/test3.out                    |  22 +++
 tests/xpath_maps/gold/test4.out                    |   6 +
 tests/xpath_maps/gold/test5.out                    |   4 +
 tests/xpath_maps/gold/test6.out                    |  32 +++++
 tests/xpath_maps/gold/test7.out                    |   5 +
 tests/xpath_maps/test1.xsl                         |   4 +-
 tests/xpath_maps/{test1.xsl => test2.xsl}          |  34 +++--
 tests/xpath_maps/{test1.xsl => test3.xsl}          |  40 ++++--
 tests/xpath_maps/{test1.xsl => test4.xsl}          |  43 +++---
 tests/xpath_maps/{test1.xsl => test5.xsl}          |  36 ++---
 tests/xpath_maps/{test1.xsl => test6.xsl}          |  39 +++---
 tests/xpath_maps/{test1.xsl => test7.xsl}          |  39 +++---
 26 files changed, 981 insertions(+), 142 deletions(-)

diff --git a/src/org/apache/xpath/compiler/FunctionTable.java b/src/org/apache/xpath/compiler/FunctionTable.java
index 75fcf1c2..f325cd6b 100644
--- a/src/org/apache/xpath/compiler/FunctionTable.java
+++ b/src/org/apache/xpath/compiler/FunctionTable.java
@@ -426,6 +426,24 @@ public class FunctionTable
   
   /** The 'root' id. */
   public static final int FUNC_ROOT = 136;
+  
+  /** The 'map:size()' id. */
+  public static final int FUNC_MAP_SIZE = 137;
+  
+  /** The 'map:keys()' id. */
+  public static final int FUNC_MAP_KEYS = 138;
+  
+  /** The 'map:contains()' id. */
+  public static final int FUNC_MAP_CONTAINS = 139;
+  
+  /** The 'map:get()' id. */
+  public static final int FUNC_MAP_GET = 140;
+  
+  /** The 'map:put()' id. */
+  public static final int FUNC_MAP_PUT = 141;
+  
+  /** The 'map:entry()' id. */
+  public static final int FUNC_MAP_ENTRY = 142;
 
   // Proprietary
 
@@ -440,7 +458,7 @@ public class FunctionTable
    * namespace prefix for this namespace uri is "fn", as specified by
    * XPath 3.1 spec).
    */
-  static final String XPATH_BUILT_IN_FUNCS_NS_URI = "http://www.w3.org/2005/xpath-functions";
+  public static final String XPATH_BUILT_IN_FUNCS_NS_URI = "http://www.w3.org/2005/xpath-functions";
   
   /**
    * XPath 3.1 built-in functions namespace uri, for maths trigonometric and exponential 
@@ -449,7 +467,7 @@ public class FunctionTable
    * used XML namespace prefix for this namespace uri is "math", as specified by 
    * XPath 3.1 spec).
    */
-  static final String XPATH_BUILT_IN_MATH_FUNCS_NS_URI = "http://www.w3.org/2005/xpath-functions/math";
+  public static final String XPATH_BUILT_IN_MATH_FUNCS_NS_URI = "http://www.w3.org/2005/xpath-functions/math";
   
   static final Integer[] XPATH_MATH_FUNC_IDS = new Integer[] { new Integer(FUNC_MATH_PI), new Integer(FUNC_MATH_EXP),
                                                                new Integer(FUNC_MATH_EXP10), new Integer(FUNC_MATH_LOG),
@@ -467,12 +485,26 @@ public class FunctionTable
    * uri (the commonly used XML namespace prefix for this namespace uri is "array", as specified by 
    * XPath 3.1 spec).
    */
-  static final String XPATH_BUILT_IN_ARRAY_FUNCS_NS_URI = "http://www.w3.org/2005/xpath-functions/array";
+  public static final String XPATH_BUILT_IN_ARRAY_FUNCS_NS_URI = "http://www.w3.org/2005/xpath-functions/array";
     
   static final Integer[] XPATH_ARRAY_FUNC_IDS = new Integer[] { new Integer(FUNC_ARRAY_SIZE), new Integer(FUNC_ARRAY_GET),
 		                                                        new Integer(FUNC_ARRAY_PUT) };
   
-  static final List<Integer> XPATH_ARRAY_FUNC_IDS_ARR = Arrays.asList(XPATH_ARRAY_FUNC_IDS);  
+  static final List<Integer> XPATH_ARRAY_FUNC_IDS_ARR = Arrays.asList(XPATH_ARRAY_FUNC_IDS);
+  
+  /**
+   * XPath 3.1 built-in functions namespace uri, for map related functions. The XPath functions available 
+   * within this namespace, must be used by qualifying the function name with an XML namespace bound to this 
+   * uri (the commonly used XML namespace prefix for this namespace uri is "map", as specified by 
+   * XPath 3.1 spec).
+   */
+  public static final String XPATH_BUILT_IN_MAP_FUNCS_NS_URI = "http://www.w3.org/2005/xpath-functions/map";
+    
+  static final Integer[] XPATH_MAP_FUNC_IDS = new Integer[] { 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)};
+  
+  static final List<Integer> XPATH_MAP_FUNC_IDS_ARR = Arrays.asList(XPATH_MAP_FUNC_IDS);
 
   /**
    * The function table.
@@ -496,7 +528,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 = 137;
+  private static final int NUM_BUILT_IN_FUNCS = 143;
 
   /**
    * Number of built-in functions that may be added.
@@ -740,6 +772,15 @@ public class FunctionTable
     m_functions[FUNC_ARRAY_GET] = org.apache.xpath.functions.array.FuncArrayGet.class;
     m_functions[FUNC_ARRAY_PUT] = org.apache.xpath.functions.array.FuncArrayPut.class;
     
+    // XPath 3.1 built-in functions configurations for the map 
+    // functions namespace http://www.w3.org/2005/xpath-functions/map    
+    m_functions[FUNC_MAP_SIZE] = org.apache.xpath.functions.map.FuncMapSize.class;
+    m_functions[FUNC_MAP_KEYS] = org.apache.xpath.functions.map.FuncMapKeys.class;
+    m_functions[FUNC_MAP_CONTAINS] = org.apache.xpath.functions.map.FuncMapContains.class;
+    m_functions[FUNC_MAP_GET] = org.apache.xpath.functions.map.FuncMapGet.class;
+    m_functions[FUNC_MAP_PUT] = org.apache.xpath.functions.map.FuncMapPut.class;
+    m_functions[FUNC_MAP_ENTRY] = org.apache.xpath.functions.map.FuncMapEntry.class;
+    
   }
 
   static{
@@ -1008,6 +1049,21 @@ public class FunctionTable
          m_functionID.put(Keywords.FUNC_ARRAY_PUT,
                           new Integer(FunctionTable.FUNC_ARRAY_PUT));
          
+         // XPath 3.1 functions configurations for the map functions 
+         // namespace http://www.w3.org/2005/xpath-functions/map
+         m_functionID.put(Keywords.FUNC_MAP_SIZE,
+                          new Integer(FunctionTable.FUNC_MAP_SIZE));
+         m_functionID.put(Keywords.FUNC_MAP_KEYS,
+                          new Integer(FunctionTable.FUNC_MAP_KEYS));
+         m_functionID.put(Keywords.FUNC_MAP_CONTAINS,
+                         new Integer(FunctionTable.FUNC_MAP_CONTAINS));
+         m_functionID.put(Keywords.FUNC_MAP_GET,
+                         new Integer(FunctionTable.FUNC_MAP_GET));
+         m_functionID.put(Keywords.FUNC_MAP_PUT,
+                         new Integer(FunctionTable.FUNC_MAP_PUT));
+         m_functionID.put(Keywords.FUNC_MAP_ENTRY,
+                         new Integer(FunctionTable.FUNC_MAP_ENTRY));
+         
          m_functionID.put(Keywords.FUNC_NAME_STRING,
                           new Integer(FunctionTable.FUNC_NAME));
          
diff --git a/src/org/apache/xpath/compiler/Keywords.java b/src/org/apache/xpath/compiler/Keywords.java
index 58768e39..829ad0ac 100644
--- a/src/org/apache/xpath/compiler/Keywords.java
+++ b/src/org/apache/xpath/compiler/Keywords.java
@@ -566,6 +566,24 @@ public class Keywords
   /** in-scope-prefixes function string. */
   public static final String FUNC_IN_SCOPE_PREFIXES = "in-scope-prefixes";
   
+  /** map:size function string. */
+  public static final String FUNC_MAP_SIZE = "size";
+  
+  /** map:keys function string. */
+  public static final String FUNC_MAP_KEYS = "keys";
+  
+  /** map:contains function string. */
+  public static final String FUNC_MAP_CONTAINS = "contains";
+  
+  /** map:get function string. */
+  public static final String FUNC_MAP_GET = "get";
+  
+  /** map:put function string. */
+  public static final String FUNC_MAP_PUT = "put";
+  
+  /** map:entry function string. */
+  public static final String FUNC_MAP_ENTRY = "entry";
+  
   // Proprietary, built in functions
 
   /** current function string (Proprietary). */
diff --git a/src/org/apache/xpath/compiler/Lexer.java b/src/org/apache/xpath/compiler/Lexer.java
index 8f8bf91e..7a24e12b 100644
--- a/src/org/apache/xpath/compiler/Lexer.java
+++ b/src/org/apache/xpath/compiler/Lexer.java
@@ -22,7 +22,6 @@ package org.apache.xpath.compiler;
 
 import java.util.Vector;
 
-import org.apache.xml.utils.ObjectVector;
 import org.apache.xml.utils.PrefixResolver;
 import org.apache.xpath.res.XPATHErrorResources;
 
@@ -604,9 +603,10 @@ class Lexer
     {
       try
       {
-        if (prefix.length() > 0)
-          uName = ((PrefixResolver) m_namespaceContext).getNamespaceForPrefix(
-            prefix);
+        if (prefix.length() > 0) {
+           uName = ((PrefixResolver) m_namespaceContext).getNamespaceForPrefix
+        		                                                            (prefix);
+        }
         else
         {
 
diff --git a/src/org/apache/xpath/compiler/XPathParserImpl.java b/src/org/apache/xpath/compiler/XPathParserImpl.java
index 9f5ed7e3..2110f7a8 100644
--- a/src/org/apache/xpath/compiler/XPathParserImpl.java
+++ b/src/org/apache/xpath/compiler/XPathParserImpl.java
@@ -784,28 +784,6 @@ public class XPathParserImpl
      
      return isStrHasBalancedParentheses; 
   }
-
-  /**
-   * Notify the user of an assertion error, and probably throw an
-   * exception.
-   *
-   * @param b  If false, a runtime exception will be thrown.
-   * @param msg The assertion message, which should be informative.
-   * 
-   * @throws RuntimeException if the b argument is false.
-   */
-  private void assertion(boolean b, String msg)
-  {
-
-    if (!b)
-    {
-      String fMsg = XSLMessages.createXPATHMessage(
-        XPATHErrorResources.ER_INCORRECT_PROGRAMMER_ASSERTION,
-        new Object[]{ msg });
-
-      throw new RuntimeException(fMsg);
-    }
-  }
   
   /**
    * This method helps to implement, XPath 3.1 sequence type expressions.
@@ -1041,7 +1019,7 @@ public class XPathParserImpl
    *    values found in {@link org.apache.xpath.compiler.FunctionTable}, but may 
    *    be a value installed by an external module.
    */
-  final int getFunctionToken(String key)
+  final int getFunctionToken(String key, String nsUri)
   {
 
     int tok;
@@ -1053,7 +1031,50 @@ public class XPathParserImpl
       // These are nodetests, xpathparser treats them as functions when parsing
       // a FilterExpr. 
       id = Keywords.lookupNodeTest(key);
-      if (null == id) id = m_functionTable.getFunctionID(key);
+      if (id == null) {
+    	if ((FunctionTable.XPATH_BUILT_IN_FUNCS_NS_URI).equals(nsUri)) {
+    	   if ("contains".equals(key)) {
+      		  id = FunctionTable.FUNC_CONTAINS;  
+      	   }
+    	   else {
+    		  id = m_functionTable.getFunctionID(key); 
+    	   }
+    	}
+    	else if ((FunctionTable.XPATH_BUILT_IN_ARRAY_FUNCS_NS_URI).equals(nsUri)) {
+    	   if ("size".equals(key)) {
+        	  id = FunctionTable.FUNC_ARRAY_SIZE;   
+           }
+    	   else if ("get".equals(key)) {
+    		  id = FunctionTable.FUNC_ARRAY_GET; 
+    	   }
+    	   else if ("put".equals(key)) {
+     		  id = FunctionTable.FUNC_ARRAY_PUT; 
+     	   }
+    	   else {
+    		  id = m_functionTable.getFunctionID(key); 
+    	   }
+    	}
+    	else if ((FunctionTable.XPATH_BUILT_IN_MAP_FUNCS_NS_URI).equals(nsUri)) {
+    	   if ("size".equals(key)) {
+          	  id = FunctionTable.FUNC_MAP_SIZE;   
+           }
+    	   else if ("get".equals(key)) {
+     		  id = FunctionTable.FUNC_MAP_GET; 
+     	   }
+    	   else if ("put".equals(key)) {
+      		  id = FunctionTable.FUNC_MAP_PUT; 
+      	   }
+    	   else if ("contains".equals(key)) {
+    		  id = FunctionTable.FUNC_MAP_CONTAINS;  
+    	   }
+    	   else {
+     		  id = m_functionTable.getFunctionID(key); 
+     	   }
+    	}
+    	else {
+    	   id = m_functionTable.getFunctionID(key);
+    	}
+      }
       tok = ((Integer) id).intValue();
     }
     catch (NullPointerException npe)
@@ -1285,25 +1306,31 @@ public class XPathParserImpl
           nextToken();
 
           insertOp(opPos, 2, OpCodes.OP_MAP_CONSTRUCTOR_EXPR);
+          
           fMapConstructor = new MapConstructor();
           Map<String, String> nativeMapVar = new HashMap<String, String>();
           
           consumeExpected('{');
           
-          while (m_token != null) {        	 
-        	 String mapKeyExprStr = m_token;
-        	 nextToken();
-        	 consumeExpected(':');
-        	 String mapValueExprStr = m_token;        	 
-        	 nativeMapVar.put(mapKeyExprStr, mapValueExprStr);
-        	 nextToken();
-        	 if (tokenIs(',')) {
-        		consumeExpected(','); 
-        	 }
-        	 else if (tokenIs('}')) {
-        		consumeExpected('}');
-        		break;
-        	 }
+          if (!(tokenIs('}') && (getTokenRelative(1) == null))) {
+        	  while (m_token != null) {        	 
+ 	        	 String mapKeyExprStr = m_token;
+ 	        	 nextToken();
+ 	        	 consumeExpected(':');
+ 	        	 String mapValueExprStr = m_token;        	 
+ 	        	 nativeMapVar.put(mapKeyExprStr, mapValueExprStr);
+ 	        	 nextToken();
+ 	        	 if (tokenIs(',')) {
+ 	        		consumeExpected(','); 
+ 	        	 }
+ 	        	 else if (tokenIs('}')) {
+ 	        		consumeExpected('}');
+ 	        		break;
+ 	        	 }
+ 	          }    
+          }
+          else {
+        	  consumeExpected('}'); 
           }
           
           fMapConstructor.setNativeMap(nativeMapVar);
@@ -2811,7 +2838,7 @@ public class XPathParserImpl
          nextToken();
          consumeExpected(':');
          
-         int funcTok = getFunctionToken(m_token);
+         int funcTok = getFunctionToken(m_token, FunctionTable.XPATH_BUILT_IN_FUNCS_NS_URI);
 
          if (-1 == funcTok)
          {
@@ -2828,6 +2855,11 @@ public class XPathParserImpl
              error(XPATHErrorResources.ER_COULDNOT_FIND_FUNCTION,
                    new Object[] {"{" + FunctionTable.XPATH_BUILT_IN_FUNCS_NS_URI + "}" + m_token + "()"});  
          }
+         else if ((FunctionTable.XPATH_MAP_FUNC_IDS_ARR).contains(Integer.valueOf(funcTok))) {
+             funcTok = -1;
+             error(XPATHErrorResources.ER_COULDNOT_FIND_FUNCTION,
+                   new Object[] {"{" + FunctionTable.XPATH_BUILT_IN_FUNCS_NS_URI + "}" + m_token + "()"});  
+         }
 
          switch (funcTok)
          {
@@ -2850,7 +2882,7 @@ public class XPathParserImpl
          nextToken();
          consumeExpected(':');
          
-         int funcTok = getFunctionToken(m_token);
+         int funcTok = getFunctionToken(m_token, FunctionTable.XPATH_BUILT_IN_MATH_FUNCS_NS_URI);
 
          if (-1 == funcTok)
          {
@@ -2884,7 +2916,7 @@ public class XPathParserImpl
          nextToken();
          consumeExpected(':');
          
-         int funcTok = getFunctionToken(m_token);
+         int funcTok = getFunctionToken(m_token, FunctionTable.XPATH_BUILT_IN_ARRAY_FUNCS_NS_URI);
 
          if (-1 == funcTok)
          {
@@ -2913,6 +2945,40 @@ public class XPathParserImpl
 
          nextToken();
       }
+      else if (tokenIs(FunctionTable.XPATH_BUILT_IN_MAP_FUNCS_NS_URI)) 
+      {
+         nextToken();
+         consumeExpected(':');
+         
+         int funcTok = getFunctionToken(m_token, FunctionTable.XPATH_BUILT_IN_MAP_FUNCS_NS_URI);
+
+         if (-1 == funcTok)
+         {
+             error(XPATHErrorResources.ER_COULDNOT_FIND_FUNCTION,
+                 new Object[] {"{" + FunctionTable.XPATH_BUILT_IN_MAP_FUNCS_NS_URI + "}" + m_token + "()"});
+         }
+         else if (!(FunctionTable.XPATH_MAP_FUNC_IDS_ARR).contains(Integer.valueOf(funcTok))) {
+             funcTok = -1;
+             error(XPATHErrorResources.ER_COULDNOT_FIND_FUNCTION,
+                   new Object[] {"{" + FunctionTable.XPATH_BUILT_IN_ARRAY_FUNCS_NS_URI + "}" + m_token + "()"});  
+         }
+
+         switch (funcTok)
+         {
+            case OpCodes.NODETYPE_PI :
+            case OpCodes.NODETYPE_COMMENT :
+            case OpCodes.NODETYPE_TEXT :
+            case OpCodes.NODETYPE_NODE :
+              // Node type tests look like function calls, but they're not
+              return false;
+            default :
+              appendOp(3, OpCodes.OP_FUNCTION);
+
+            m_ops.setOp(opPos + OpMap.MAPINDEX_LENGTH + 1, funcTok);
+         }
+
+         nextToken();
+      }
       else {  
         appendOp(4, OpCodes.OP_EXTFUNCTION);
 
@@ -2928,7 +2994,7 @@ public class XPathParserImpl
     }
     else
     {
-      int funcTok = getFunctionToken(m_token);
+      int funcTok = getFunctionToken(m_token, FunctionTable.XPATH_BUILT_IN_FUNCS_NS_URI);
 
       if (funcTok == -1)
       {
@@ -2945,6 +3011,11 @@ public class XPathParserImpl
           error(XPATHErrorResources.ER_COULDNOT_FIND_FUNCTION,
                 new Object[] {"{" + FunctionTable.XPATH_BUILT_IN_FUNCS_NS_URI + "}" + m_token + "()"});  
       }
+      else if ((FunctionTable.XPATH_MAP_FUNC_IDS_ARR).contains(Integer.valueOf(funcTok))) {
+          funcTok = -1;
+          error(XPATHErrorResources.ER_COULDNOT_FIND_FUNCTION,
+                new Object[] {"{" + FunctionTable.XPATH_BUILT_IN_FUNCS_NS_URI + "}" + m_token + "()"});  
+      }
 
       switch (funcTok)
       {
diff --git a/src/org/apache/xpath/functions/map/FuncMapContains.java b/src/org/apache/xpath/functions/map/FuncMapContains.java
new file mode 100644
index 00000000..561cc8af
--- /dev/null
+++ b/src/org/apache/xpath/functions/map/FuncMapContains.java
@@ -0,0 +1,76 @@
+/*
+ * 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.Map;
+
+import javax.xml.transform.SourceLocator;
+
+import org.apache.xpath.Expression;
+import org.apache.xpath.XPathContext;
+import org.apache.xpath.functions.Function2Args;
+import org.apache.xpath.objects.XObject;
+import org.apache.xpath.objects.XPathMap;
+import org.apache.xpath.operations.Variable;
+
+import xml.xpath31.processor.types.XSBoolean;
+
+/**
+ * Implementation of an map:contains function.
+ * 
+ * @author Mukul Gandhi <mu...@apache.org>
+ * 
+ * @xsl.usage advanced
+ */
+public class FuncMapContains extends Function2Args {
+
+	private static final long serialVersionUID = -749857579667076961L;
+
+	public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
+	{
+		XObject result = null;
+	       
+	    SourceLocator srcLocator = xctxt.getSAXLocator();
+	       
+	    Expression arg0 = getArg0();
+	    XPathMap xpathMap = null;
+	    
+	    if (arg0 instanceof Variable) {
+	       XObject xObject = ((Variable)arg0).execute(xctxt);
+	       xpathMap = (XPathMap)xObject;
+	    }
+	    else {
+	       XObject xObject = arg0.execute(xctxt);
+		   xpathMap = (XPathMap)xObject;
+	    }
+	    
+	    Map<XObject, XObject> nativeMap = xpathMap.getNativeMap();
+	    
+	    Expression arg1 = getArg1();
+	    XObject arg1Obj = arg1.execute(xctxt);
+	    
+	    if (nativeMap.get(arg1Obj) != null) {
+	       result = new XSBoolean(true);	
+	    }
+	    else {
+	       result = new XSBoolean(false);	
+	    }
+	    
+	    return result;
+	}
+
+}
diff --git a/src/org/apache/xpath/functions/map/FuncMapEntry.java b/src/org/apache/xpath/functions/map/FuncMapEntry.java
new file mode 100644
index 00000000..12733895
--- /dev/null
+++ b/src/org/apache/xpath/functions/map/FuncMapEntry.java
@@ -0,0 +1,73 @@
+/*
+ * 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 javax.xml.transform.SourceLocator;
+
+import org.apache.xpath.Expression;
+import org.apache.xpath.XPathContext;
+import org.apache.xpath.functions.Function2Args;
+import org.apache.xpath.objects.XObject;
+import org.apache.xpath.objects.XPathMap;
+import org.apache.xpath.operations.Variable;
+
+/**
+ * Implementation of an map:entry function.
+ * 
+ * @author Mukul Gandhi <mu...@apache.org>
+ * 
+ * @xsl.usage advanced
+ */
+public class FuncMapEntry extends Function2Args {
+
+	private static final long serialVersionUID = -1419049097023024612L;
+
+	public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
+	{
+		XObject result = null;
+	       
+	    SourceLocator srcLocator = xctxt.getSAXLocator();
+	       
+	    Expression arg0 = getArg0();
+	    Expression arg1 = getArg1();
+	    
+	    XObject resultMapEntryKey = null;
+	    XObject resultMapEntryVal = null;
+	    
+	    if (arg0 instanceof Variable) {
+	       resultMapEntryKey = ((Variable)arg0).execute(xctxt);
+	    }
+	    else {
+	       resultMapEntryKey = arg0.execute(xctxt);
+	    }
+	    
+	    if (arg1 instanceof Variable) {
+	       resultMapEntryVal = ((Variable)arg1).execute(xctxt);
+		}
+		else {
+		   resultMapEntryVal = arg1.execute(xctxt);
+		}
+	    
+	    XPathMap resultMap = new XPathMap();
+	    resultMap.put(resultMapEntryKey, resultMapEntryVal);
+	    
+	    result = resultMap;
+	    
+	    return result;
+	}
+
+}
diff --git a/src/org/apache/xpath/functions/map/FuncMapGet.java b/src/org/apache/xpath/functions/map/FuncMapGet.java
new file mode 100644
index 00000000..375b29ba
--- /dev/null
+++ b/src/org/apache/xpath/functions/map/FuncMapGet.java
@@ -0,0 +1,77 @@
+/*
+ * 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.Map;
+
+import javax.xml.transform.SourceLocator;
+
+import org.apache.xalan.xslt.util.XslTransformEvaluationHelper;
+import org.apache.xpath.Expression;
+import org.apache.xpath.XPathContext;
+import org.apache.xpath.functions.Function2Args;
+import org.apache.xpath.objects.ResultSequence;
+import org.apache.xpath.objects.XNodeSet;
+import org.apache.xpath.objects.XObject;
+import org.apache.xpath.objects.XPathMap;
+import org.apache.xpath.operations.Variable;
+
+import xml.xpath31.processor.types.XSBoolean;
+
+/**
+ * Implementation of an map:get function.
+ * 
+ * @author Mukul Gandhi <mu...@apache.org>
+ * 
+ * @xsl.usage advanced
+ */
+public class FuncMapGet extends Function2Args {
+
+	private static final long serialVersionUID = -749857579667076961L;
+
+	public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
+	{
+		XObject result = null;
+	       
+	    SourceLocator srcLocator = xctxt.getSAXLocator();
+	       
+	    Expression arg0 = getArg0();
+	    XPathMap xpathMap = null;
+	    
+	    if (arg0 instanceof Variable) {
+	       XObject xObject = ((Variable)arg0).execute(xctxt);
+	       xpathMap = (XPathMap)xObject;
+	    }
+	    else {
+	       XObject xObject = arg0.execute(xctxt);
+		   xpathMap = (XPathMap)xObject;
+	    }
+	    
+	    Map<XObject, XObject> nativeMap = xpathMap.getNativeMap();
+	    
+	    Expression arg1 = getArg1();
+	    XObject arg1Obj = arg1.execute(xctxt);
+	    
+	    result = nativeMap.get(arg1Obj);
+	    if (result == null) {
+	       result = new ResultSequence();	
+	    }
+	    
+	    return result;
+	}
+
+}
diff --git a/src/org/apache/xpath/functions/map/FuncMapKeys.java b/src/org/apache/xpath/functions/map/FuncMapKeys.java
new file mode 100644
index 00000000..a830f961
--- /dev/null
+++ b/src/org/apache/xpath/functions/map/FuncMapKeys.java
@@ -0,0 +1,78 @@
+/*
+ * 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.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.transform.SourceLocator;
+
+import org.apache.xpath.Expression;
+import org.apache.xpath.XPathContext;
+import org.apache.xpath.functions.FunctionOneArg;
+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 map:keys function.
+ * 
+ * @author Mukul Gandhi <mu...@apache.org>
+ * 
+ * @xsl.usage advanced
+ */
+public class FuncMapKeys extends FunctionOneArg {
+	
+	private static final long serialVersionUID = -7109316358636297324L;
+
+	public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
+	{
+		ResultSequence resultSeq = new ResultSequence();
+	       
+	    SourceLocator srcLocator = xctxt.getSAXLocator();
+	       
+	    Expression arg0 = getArg0();
+	    
+	    if (arg0 instanceof Variable) {
+	       XObject xObject = ((Variable)arg0).execute(xctxt);
+	       XPathMap xpathMap = (XPathMap)xObject;
+	       Map<XObject, XObject> nativeMap = xpathMap.getNativeMap();
+	       Set<XObject> keySet = nativeMap.keySet();
+	       Iterator<XObject> iter = keySet.iterator();
+	       while (iter.hasNext()) {
+	    	  XObject keyVal = iter.next();
+	    	  resultSeq.add(keyVal);
+	       }
+	    }
+	    else {
+	    	XObject xObject = arg0.execute(xctxt);
+		    XPathMap xpathMap = (XPathMap)xObject;
+		    Map<XObject, XObject> nativeMap = xpathMap.getNativeMap();
+		    Set<XObject> keySet = nativeMap.keySet();
+		    Iterator<XObject> iter = keySet.iterator();
+		    while (iter.hasNext()) {
+		       XObject keyVal = iter.next();
+		       resultSeq.add(keyVal);  
+		    }
+	    }
+	    
+	    return resultSeq;
+	}
+
+}
diff --git a/src/org/apache/xpath/functions/map/FuncMapPut.java b/src/org/apache/xpath/functions/map/FuncMapPut.java
new file mode 100644
index 00000000..b6319369
--- /dev/null
+++ b/src/org/apache/xpath/functions/map/FuncMapPut.java
@@ -0,0 +1,94 @@
+/*
+ * 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.Map;
+
+import javax.xml.transform.SourceLocator;
+
+import org.apache.xpath.Expression;
+import org.apache.xpath.XPathContext;
+import org.apache.xpath.functions.Function3Args;
+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 map:put function.
+ * 
+ * @author Mukul Gandhi <mu...@apache.org>
+ * 
+ * @xsl.usage advanced
+ */
+public class FuncMapPut extends Function3Args {
+
+	private static final long serialVersionUID = -749857579667076961L;
+
+	public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
+	{
+		XObject result = null;
+	       
+	    SourceLocator srcLocator = xctxt.getSAXLocator();
+	       
+	    Expression arg0 = getArg0();   // 'map' argument
+	    XPathMap xpathMap = null;
+	    
+	    if (arg0 instanceof Variable) {
+	       XObject xObject = ((Variable)arg0).execute(xctxt);
+	       xpathMap = (XPathMap)xObject;
+	    }
+	    else {
+	       XObject xObject = arg0.execute(xctxt);
+		   xpathMap = (XPathMap)xObject;
+	    }
+	    
+	    Map<XObject, XObject> nativeMap = xpathMap.getNativeMap();
+	    
+	    Expression arg1 = getArg1();    // 'key' argument
+	    XObject arg1Obj = arg1.execute(xctxt);
+	    ResultSequence mapEntryKey = null;
+	    if (!(arg1Obj instanceof ResultSequence)) {
+	       mapEntryKey = new ResultSequence();
+	       mapEntryKey.add(arg1Obj);	       
+	    }
+	    else {
+	       mapEntryKey = (ResultSequence)arg1Obj;
+	    }
+	    
+	    Expression arg2 = getArg2();   // 'value' argument
+	    XObject arg2Obj = arg2.execute(xctxt);
+	    ResultSequence mapEntryValue = null;
+	    if (!(arg2Obj instanceof ResultSequence)) {
+	       mapEntryValue = new ResultSequence();
+	       mapEntryValue.add(arg2Obj);	       
+	    }
+	    else {
+	       mapEntryValue = (ResultSequence)arg2Obj; 
+	    }
+	    
+	    nativeMap.put(mapEntryKey, mapEntryValue);
+	    
+	    XPathMap xpathMapResult = new XPathMap();
+	    xpathMapResult.setNativeMap(nativeMap);
+	    
+	    result = xpathMapResult; 
+	    	    
+	    return result;
+	}
+
+}
diff --git a/src/org/apache/xpath/functions/map/FuncMapSize.java b/src/org/apache/xpath/functions/map/FuncMapSize.java
new file mode 100644
index 00000000..b2c633cb
--- /dev/null
+++ b/src/org/apache/xpath/functions/map/FuncMapSize.java
@@ -0,0 +1,63 @@
+/*
+ * 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 javax.xml.transform.SourceLocator;
+
+import org.apache.xpath.Expression;
+import org.apache.xpath.XPathContext;
+import org.apache.xpath.functions.FunctionOneArg;
+import org.apache.xpath.objects.XObject;
+import org.apache.xpath.objects.XPathMap;
+import org.apache.xpath.operations.Variable;
+
+import xml.xpath31.processor.types.XSInteger;
+
+/**
+ * Implementation of the map:size function.
+ * 
+ * @author Mukul Gandhi <mu...@apache.org>
+ * 
+ * @xsl.usage advanced
+ */
+public class FuncMapSize extends FunctionOneArg {
+
+	private static final long serialVersionUID = 5600653040311629451L;
+	
+	public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
+	{
+	    XObject result = null;
+	       
+	    SourceLocator srcLocator = xctxt.getSAXLocator();
+	       
+	    Expression arg0 = getArg0();
+	    
+	    if (arg0 instanceof Variable) {
+	       XObject xObject = ((Variable)arg0).execute(xctxt);
+	       XPathMap xpathMap = (XPathMap)xObject;
+	       result = new XSInteger(String.valueOf(xpathMap.size()));
+	    }
+	    else {
+	    	XObject xObject = arg0.execute(xctxt);
+		    XPathMap xpathMap = (XPathMap)xObject;
+		    result = new XSInteger(String.valueOf(xpathMap.size()));
+	    }
+	    
+	    return result;
+	}
+
+}
diff --git a/src/org/apache/xpath/objects/XObject.java b/src/org/apache/xpath/objects/XObject.java
index d2ceb7d3..3b4eba4c 100644
--- a/src/org/apache/xpath/objects/XObject.java
+++ b/src/org/apache/xpath/objects/XObject.java
@@ -1156,6 +1156,28 @@ public class XObject extends Expression implements Serializable, Cloneable
 	  return isEquals; 
   }
   
+  public boolean equals(Object obj2) {
+	 boolean isEqual = false;
+	 
+	 try {
+		if (obj2 instanceof ResultSequence) {
+		   obj2 = ((ResultSequence)obj2).item(0);	
+		}		
+		isEqual = this.vcEquals((XObject)obj2, null, true);
+	 } 
+	 catch (TransformerException ex) {
+	    // no op
+	 }
+	 
+	 return isEqual;
+  }
+  
+  public int hashCode() {
+	 String strVal = this.str();
+	 
+	 return strVal.hashCode();
+  }
+  
   /**
    * Tell if two objects are functionally equal, using the rules 
    * of value comparison operator "eq".
diff --git a/src/org/apache/xpath/objects/XPathMap.java b/src/org/apache/xpath/objects/XPathMap.java
index 3bec4e0f..9cb7e983 100644
--- a/src/org/apache/xpath/objects/XPathMap.java
+++ b/src/org/apache/xpath/objects/XPathMap.java
@@ -28,10 +28,10 @@ import java.util.Map;
  */
 public class XPathMap extends XObject {
 	
-	private static final long serialVersionUID = -6876597720235822722L;
+   private static final long serialVersionUID = -6876597720235822722L;
 	
-	// the underlying native map object, to store items of an XPath map 
-    private Map<XObject, XObject> fMap = new HashMap<XObject, XObject>();
+   // the underlying native map object, to store items of an XPath map 
+   private Map<XObject, XObject> fMap = new HashMap<XObject, XObject>();
     
    /*
     * Class constructor.
@@ -60,10 +60,17 @@ public class XPathMap extends XObject {
    /**
     * Get native contents of this map object.
     */
-   public Map<XObject, XObject> getMap() {
+   public Map<XObject, XObject> getNativeMap() {
        return fMap;   
    }
    
+   /**
+    * Set a new native map object, as content of this XPath map.
+    */
+   public void setNativeMap(Map mapObj) {
+      fMap = mapObj;
+   }
+   
    /**
     * Get number of entries in this map.
     */
diff --git a/tests/org/apache/xalan/xpath3/XPathMapTests.java b/tests/org/apache/xalan/xpath3/XPathMapTests.java
index 25ad7248..d6f0e1f5 100644
--- a/tests/org/apache/xalan/xpath3/XPathMapTests.java
+++ b/tests/org/apache/xalan/xpath3/XPathMapTests.java
@@ -23,7 +23,8 @@ import org.junit.BeforeClass;
 import org.junit.Test;
 
 /**
- * XPath 3.1 test cases, to test XPath map expressions.
+ * XPath 3.1 test cases, to test XPath 'map' expressions 
+ * and 'map' functions.
  * 
  * @author Mukul Gandhi <mu...@apache.org>
  * 
@@ -56,5 +57,65 @@ public class XPathMapTests extends XSLTransformTestsUtil {
         
         runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
     }
+    
+    @Test
+    public void xslMapTest2() {
+        String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test2.xsl"; 
+        String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test2.xsl";
+        
+        String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test2.out";                
+        
+        runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+    }
+    
+    @Test
+    public void xslMapTest3() {
+        String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test3.xsl"; 
+        String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test3.xsl";
+        
+        String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test3.out";                
+        
+        runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+    }
+    
+    @Test
+    public void xslMapTest4() {
+        String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test4.xsl"; 
+        String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test4.xsl";
+        
+        String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test4.out";                
+        
+        runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+    }
+    
+    @Test
+    public void xslMapTest5() {
+        String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test5.xsl"; 
+        String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test5.xsl";
+        
+        String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test5.out";                
+        
+        runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+    }
+    
+    @Test
+    public void xslMapTest6() {
+        String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test6.xsl"; 
+        String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test6.xsl";
+        
+        String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test6.out";                
+        
+        runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+    }
+    
+    @Test
+    public void xslMapTest7() {
+        String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test7.xsl"; 
+        String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test7.xsl";
+        
+        String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test7.out";                
+        
+        runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+    }
 
 }
diff --git a/tests/xpath_maps/gold/test2.out b/tests/xpath_maps/gold/test2.out
new file mode 100644
index 00000000..460fcfc6
--- /dev/null
+++ b/tests/xpath_maps/gold/test2.out
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?><result>
+  <map name="weekDaysMap">
+    <size>7</size>
+  </map>
+  <map name="boolMap">
+    <size>2</size>
+  </map>
+  <map name="emptyMap">
+    <size>0</size>
+  </map>
+</result>
diff --git a/tests/xpath_maps/gold/test3.out b/tests/xpath_maps/gold/test3.out
new file mode 100644
index 00000000..7854314e
--- /dev/null
+++ b/tests/xpath_maps/gold/test3.out
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?><result>
+  <map>
+    <keys>
+      <val>Tu</val>
+      <val>Mo</val>
+      <val>Su</val>
+      <val>Th</val>
+      <val>Fr</val>
+      <val>Sa</val>
+      <val>We</val>
+    </keys>
+  </map>
+  <map>
+    <keys>
+      <val>1</val>
+      <val>2</val>
+    </keys>
+  </map>
+  <map>
+    <keys/>
+  </map>
+</result>
diff --git a/tests/xpath_maps/gold/test4.out b/tests/xpath_maps/gold/test4.out
new file mode 100644
index 00000000..898c5aa3
--- /dev/null
+++ b/tests/xpath_maps/gold/test4.out
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?><contains>
+  <one>true</one>
+  <two>false</two>
+  <three>false</three>
+  <four>true</four>
+</contains>
diff --git a/tests/xpath_maps/gold/test5.out b/tests/xpath_maps/gold/test5.out
new file mode 100644
index 00000000..6ce399e5
--- /dev/null
+++ b/tests/xpath_maps/gold/test5.out
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?><mapGetResult>
+  <one>Donnerstag</one>
+  <two>true</two>
+</mapGetResult>
diff --git a/tests/xpath_maps/gold/test6.out b/tests/xpath_maps/gold/test6.out
new file mode 100644
index 00000000..2a313e16
--- /dev/null
+++ b/tests/xpath_maps/gold/test6.out
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?><mapPutResult>
+  <mapNewContents>
+    <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>Sonnabend</value>
+    </entry>
+  </mapNewContents>
+</mapPutResult>
diff --git a/tests/xpath_maps/gold/test7.out b/tests/xpath_maps/gold/test7.out
new file mode 100644
index 00000000..947b711c
--- /dev/null
+++ b/tests/xpath_maps/gold/test7.out
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?><result>
+  <one>hello</one>
+  <two>hi</two>
+  <three>there</three>
+</result>
diff --git a/tests/xpath_maps/test1.xsl b/tests/xpath_maps/test1.xsl
index 756b234a..dfb2f197 100644
--- a/tests/xpath_maps/test1.xsl
+++ b/tests/xpath_maps/test1.xsl
@@ -6,8 +6,8 @@
 
    <xsl:output method="text"/>
    
-   <!-- An XPath 3.1 test case, to test XPath 'map' expressions. The XPath expressions 
-        used within this stylesheet test case, are borrowed from XPath 3.1 spec. -->   
+   <!-- An XPath 3.1 test case, to test an XPath 'map' 
+        expression. -->   
 
    <xsl:template match="/">
       <xsl:variable name="map1" select="map {
diff --git a/tests/xpath_maps/test1.xsl b/tests/xpath_maps/test2.xsl
similarity index 63%
copy from tests/xpath_maps/test1.xsl
copy to tests/xpath_maps/test2.xsl
index 756b234a..278ac963 100644
--- a/tests/xpath_maps/test1.xsl
+++ b/tests/xpath_maps/test2.xsl
@@ -1,13 +1,15 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-                version="3.0">
-                
+                xmlns:map="http://www.w3.org/2005/xpath-functions/map"
+				exclude-result-prefixes="map"
+                version="3.0">				
+
    <!-- Author: mukulg@apache.org -->                
 
-   <xsl:output method="text"/>
+   <xsl:output method="xml" indent="yes"/>
    
-   <!-- An XPath 3.1 test case, to test XPath 'map' expressions. The XPath expressions 
-        used within this stylesheet test case, are borrowed from XPath 3.1 spec. -->   
+   <!-- An XPath 3.1 test case, to test an XPath map:size 
+        function. -->
 
    <xsl:template match="/">
       <xsl:variable name="map1" select="map {
@@ -18,9 +20,25 @@
 			  'Th' : 'Thursday',
 			  'Fr' : 'Friday',
 			  'Sa' : 'Saturday'}"/>
-			  
-	  <!-- map lookup using function call syntax -->
-	  <xsl:value-of select="$map1('Su')"/>
+	  <xsl:variable name="map2" select="map {'true' : 1, 'false' : 0}"/>
+	  <xsl:variable name="map3" select="map {}"/>
+      <result>
+         <map name="weekDaysMap">   	  
+	       <size>
+		      <xsl:value-of select="map:size($map1)"/>
+		   </size>
+		 </map>
+		 <map name="boolMap">   	  
+	       <size>
+		      <xsl:value-of select="map:size($map2)"/>
+		   </size>
+		 </map>
+		 <map name="emptyMap">   	  
+	       <size>
+		      <xsl:value-of select="map:size($map3)"/>
+		   </size>
+		 </map>
+	  </result>
    </xsl:template>
    
    <!--
diff --git a/tests/xpath_maps/test1.xsl b/tests/xpath_maps/test3.xsl
similarity index 59%
copy from tests/xpath_maps/test1.xsl
copy to tests/xpath_maps/test3.xsl
index 756b234a..3d70c721 100644
--- a/tests/xpath_maps/test1.xsl
+++ b/tests/xpath_maps/test3.xsl
@@ -1,13 +1,15 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-                version="3.0">
-                
+                xmlns:map="http://www.w3.org/2005/xpath-functions/map"
+				exclude-result-prefixes="map"
+                version="3.0">				
+
    <!-- Author: mukulg@apache.org -->                
 
-   <xsl:output method="text"/>
+   <xsl:output method="xml" indent="yes"/>
    
-   <!-- An XPath 3.1 test case, to test XPath 'map' expressions. The XPath expressions 
-        used within this stylesheet test case, are borrowed from XPath 3.1 spec. -->   
+   <!-- An XPath 3.1 test case, to test an XPath map:keys 
+        function. -->
 
    <xsl:template match="/">
       <xsl:variable name="map1" select="map {
@@ -18,9 +20,31 @@
 			  'Th' : 'Thursday',
 			  'Fr' : 'Friday',
 			  'Sa' : 'Saturday'}"/>
-			  
-	  <!-- map lookup using function call syntax -->
-	  <xsl:value-of select="$map1('Su')"/>
+	  <xsl:variable name="map2" select="map{1 : 'yes', 2 : 'no'}"/>
+	  <xsl:variable name="map3" select="map {}"/>
+      <result>
+         <map>
+		   <keys>
+		     <xsl:for-each select="map:keys($map1)">
+			   <val><xsl:value-of select="."/></val>
+			 </xsl:for-each>
+		   </keys>
+		 </map>
+		 <map>   	  
+	       <keys>
+		     <xsl:for-each select="map:keys($map2)">
+			   <val><xsl:value-of select="."/></val>
+			 </xsl:for-each>
+		   </keys>
+		 </map>
+		 <map>   	  
+	       <keys>
+		     <xsl:for-each select="map:keys($map3)">
+			   <val><xsl:value-of select="."/></val>
+			 </xsl:for-each>
+		   </keys>
+		 </map>
+	  </result>
    </xsl:template>
    
    <!--
diff --git a/tests/xpath_maps/test1.xsl b/tests/xpath_maps/test4.xsl
similarity index 52%
copy from tests/xpath_maps/test1.xsl
copy to tests/xpath_maps/test4.xsl
index 756b234a..43c6433c 100644
--- a/tests/xpath_maps/test1.xsl
+++ b/tests/xpath_maps/test4.xsl
@@ -1,26 +1,35 @@
 <?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 -->                
+                xmlns:map="http://www.w3.org/2005/xpath-functions/map"
+				exclude-result-prefixes="map"
+                version="3.0">				
 
-   <xsl:output method="text"/>
+  <!-- Author: mukulg@apache.org -->                
+
+   <xsl:output method="xml" indent="yes"/>
    
-   <!-- An XPath 3.1 test case, to test XPath 'map' expressions. The XPath expressions 
-        used within this stylesheet test case, are borrowed from XPath 3.1 spec. -->   
+   <!-- An XPath 3.1 test case, to test an XPath map:contains 
+        function. -->
 
    <xsl:template match="/">
-      <xsl:variable name="map1" select="map {
-			  'Su' : 'Sunday',
-			  'Mo' : 'Monday',
-			  'Tu' : 'Tuesday',
-			  'We' : 'Wednesday',
-			  'Th' : 'Thursday',
-			  'Fr' : 'Friday',
-			  'Sa' : 'Saturday'}"/>
-			  
-	  <!-- map lookup using function call syntax -->
-	  <xsl:value-of select="$map1('Su')"/>
+      <xsl:variable name="map1" select="map{ 0 : 'Sonntag', 1 : 'Montag', 2 : 'Dienstag',
+                                            3 : 'Mittwoch', 4 : 'Donnerstag', 5 : 'Freitag', 6 : 'Samstag' }"/>
+      <xsl:variable name="map2" select="map{}"/>
+	  <xsl:variable name="map3" select="map{'xyz' : 23}"/>
+      <contains>
+	    <one>
+		  <xsl:value-of select="map:contains($map1, 2)"/>
+		</one>
+		<two>
+		  <xsl:value-of select="map:contains($map1, 9)"/>
+		</two>
+		<three>
+		  <xsl:value-of select="map:contains($map2, 'xyz')"/>
+		</three>
+		<four>
+		  <xsl:value-of select="map:contains($map3, 'xyz')"/>
+		</four>
+	  </contains>
    </xsl:template>
    
    <!--
diff --git a/tests/xpath_maps/test1.xsl b/tests/xpath_maps/test5.xsl
similarity index 57%
copy from tests/xpath_maps/test1.xsl
copy to tests/xpath_maps/test5.xsl
index 756b234a..739f07fd 100644
--- a/tests/xpath_maps/test1.xsl
+++ b/tests/xpath_maps/test5.xsl
@@ -1,26 +1,28 @@
 <?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 -->                
+                xmlns:map="http://www.w3.org/2005/xpath-functions/map"
+				exclude-result-prefixes="map"
+                version="3.0">				
 
-   <xsl:output method="text"/>
+  <!-- Author: mukulg@apache.org -->                
+
+   <xsl:output method="xml" indent="yes"/>
    
-   <!-- An XPath 3.1 test case, to test XPath 'map' expressions. The XPath expressions 
-        used within this stylesheet test case, are borrowed from XPath 3.1 spec. -->   
+   <!-- An XPath 3.1 test case, to test an XPath map:get 
+        function. -->
 
    <xsl:template match="/">
-      <xsl:variable name="map1" select="map {
-			  'Su' : 'Sunday',
-			  'Mo' : 'Monday',
-			  'Tu' : 'Tuesday',
-			  'We' : 'Wednesday',
-			  'Th' : 'Thursday',
-			  'Fr' : 'Friday',
-			  'Sa' : 'Saturday'}"/>
-			  
-	  <!-- map lookup using function call syntax -->
-	  <xsl:value-of select="$map1('Su')"/>
+      <xsl:variable name="map1" select="map{ 0 : 'Sonntag', 1 : 'Montag', 2 : 'Dienstag',
+                                            3 : 'Mittwoch', 4 : 'Donnerstag', 5 : 'Freitag', 6 : 'Samstag' }"/>
+      <mapGetResult>
+	    <one>
+		  <xsl:value-of select="map:get($map1, 4)"/>
+		</one>
+		<two>
+		  <xsl:variable name="mapGetResult2" select="map:get($map1, 10)"/> 
+		  <xsl:value-of select="$mapGetResult2 instance of empty-sequence()"/>
+		</two>
+	  </mapGetResult>
    </xsl:template>
    
    <!--
diff --git a/tests/xpath_maps/test1.xsl b/tests/xpath_maps/test6.xsl
similarity index 51%
copy from tests/xpath_maps/test1.xsl
copy to tests/xpath_maps/test6.xsl
index 756b234a..cdeba131 100644
--- a/tests/xpath_maps/test1.xsl
+++ b/tests/xpath_maps/test6.xsl
@@ -1,26 +1,31 @@
 <?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 -->                
+                xmlns:map="http://www.w3.org/2005/xpath-functions/map"
+				exclude-result-prefixes="map"
+                version="3.0">				
 
-   <xsl:output method="text"/>
+  <!-- Author: mukulg@apache.org -->                
+
+   <xsl:output method="xml" indent="yes"/>
    
-   <!-- An XPath 3.1 test case, to test XPath 'map' expressions. The XPath expressions 
-        used within this stylesheet test case, are borrowed from XPath 3.1 spec. -->   
+   <!-- An XPath 3.1 test case, to test an XPath map:put 
+        function. -->
 
    <xsl:template match="/">
-      <xsl:variable name="map1" select="map {
-			  'Su' : 'Sunday',
-			  'Mo' : 'Monday',
-			  'Tu' : 'Tuesday',
-			  'We' : 'Wednesday',
-			  'Th' : 'Thursday',
-			  'Fr' : 'Friday',
-			  'Sa' : 'Saturday'}"/>
-			  
-	  <!-- map lookup using function call syntax -->
-	  <xsl:value-of select="$map1('Su')"/>
+      <xsl:variable name="map1" select="map{ 0 : 'Sonntag', 1 : 'Montag', 2 : 'Dienstag',
+                                            3 : 'Mittwoch', 4 : 'Donnerstag', 5 : 'Freitag', 6 : 'Samstag' }"/>
+      <mapPutResult>
+	    <xsl:variable name="mapAfterPut" select="map:put($map1, 6, 'Sonnabend')"/>
+	    <mapNewContents>
+	       <xsl:for-each select="map:keys($mapAfterPut)"> 
+	          <entry>
+	             <xsl:variable name="keyVal" select="."/>
+	             <key><xsl:value-of select="$keyVal"/></key>
+	             <value><xsl:value-of select="map:get($mapAfterPut, $keyVal)"/></value>
+	          </entry>
+	       </xsl:for-each>
+	    </mapNewContents>
+	  </mapPutResult>
    </xsl:template>
    
    <!--
diff --git a/tests/xpath_maps/test1.xsl b/tests/xpath_maps/test7.xsl
similarity index 55%
copy from tests/xpath_maps/test1.xsl
copy to tests/xpath_maps/test7.xsl
index 756b234a..87214b8c 100644
--- a/tests/xpath_maps/test1.xsl
+++ b/tests/xpath_maps/test7.xsl
@@ -1,26 +1,31 @@
 <?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 -->                
+                xmlns:map="http://www.w3.org/2005/xpath-functions/map"
+				exclude-result-prefixes="map"
+                version="3.0">				
 
-   <xsl:output method="text"/>
+  <!-- Author: mukulg@apache.org -->                
+
+   <xsl:output method="xml" indent="yes"/>
    
-   <!-- An XPath 3.1 test case, to test XPath 'map' expressions. The XPath expressions 
-        used within this stylesheet test case, are borrowed from XPath 3.1 spec. -->   
+   <!-- An XPath 3.1 test case, to test an XPath map:entry 
+        function. -->
 
    <xsl:template match="/">
-      <xsl:variable name="map1" select="map {
-			  'Su' : 'Sunday',
-			  'Mo' : 'Monday',
-			  'Tu' : 'Tuesday',
-			  'We' : 'Wednesday',
-			  'Th' : 'Thursday',
-			  'Fr' : 'Friday',
-			  'Sa' : 'Saturday'}"/>
-			  
-	  <!-- map lookup using function call syntax -->
-	  <xsl:value-of select="$map1('Su')"/>
+      <result>
+         <xsl:variable name="map1" select="map:entry('mesg', 'hello')"/>
+         <xsl:variable name="map2" select="map:entry('mesg', 'hi')"/>
+         <xsl:variable name="map3" select="map:entry('mesg', 'there')"/>
+         <one>
+            <xsl:value-of select="map:get($map1, 'mesg')"/>
+         </one>
+         <two>
+            <xsl:value-of select="map:get($map2, 'mesg')"/>
+         </two>
+         <three>
+            <xsl:value-of select="map:get($map3, 'mesg')"/>
+         </three>
+      </result>
    </xsl:template>
    
    <!--


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