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/07/28 16:47:42 UTC

(xalan-java) branch xalan-j_xslt3.0 updated: committing improvements to xpath3.1 function implementations for fn:boolean and fn:not, along with few conformance tests as specified in spec. also committing few cosmetic refactoring changes to src code files within this dev repos branch.

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 db80085f8 committing improvements to xpath3.1 function implementations for fn:boolean and fn:not, along with few conformance tests as specified in spec. also committing few cosmetic refactoring changes to src code files within this dev repos branch.
db80085f8 is described below

commit db80085f8fb7606963b16165d5d67ad66a8b510a
Author: Mukul Gandhi <ga...@gmail.com>
AuthorDate: Sun Jul 28 22:17:28 2024 +0530

    committing improvements to xpath3.1 function implementations for fn:boolean and fn:not, along with few conformance tests as specified in spec. also committing few cosmetic refactoring changes to src code files within this dev repos branch.
---
 src/org/apache/xalan/templates/ElemAttribute.java  |  24 +-
 src/org/apache/xalan/templates/ElemCopyOf.java     |  22 +-
 src/org/apache/xalan/templates/ElemSequence.java   |  28 +-
 src/org/apache/xalan/templates/ElemValueOf.java    |  60 ++--
 src/org/apache/xalan/templates/ElemVariable.java   |  28 +-
 src/org/apache/xpath/Expression.java               |  12 -
 src/org/apache/xpath/XPath.java                    | 369 +++++++++++----------
 src/org/apache/xpath/axes/FilterExprWalker.java    |  21 +-
 src/org/apache/xpath/axes/WalkerFactory.java       |   4 -
 src/org/apache/xpath/axes/WalkingIterator.java     |   5 +-
 src/org/apache/xpath/compiler/Compiler.java        |  11 +-
 src/org/apache/xpath/compiler/Keywords.java        |  42 +--
 src/org/apache/xpath/compiler/XPathParser.java     |  30 +-
 .../xpath/composite/XPathArrayConstructor.java     |  22 +-
 .../xpath/composite/XPathMapConstructor.java       |  51 +--
 .../xpath/composite/XPathSequenceConstructor.java  |  16 +-
 src/org/apache/xpath/functions/FuncBoolean.java    | 162 ++++-----
 src/org/apache/xpath/functions/FuncFilter.java     |  24 +-
 src/org/apache/xpath/functions/FuncForEach.java    |  32 +-
 src/org/apache/xpath/functions/FuncNot.java        |  49 +--
 src/org/apache/xpath/functions/FunctionOneArg.java |   6 +-
 .../xpath/functions/array/FuncArrayFilter.java     |  24 +-
 .../xpath/functions/array/FuncArrayForEach.java    |  28 +-
 .../apache/xpath/functions/map/FuncMapForEach.java |  28 +-
 tests/func_boolean_values/gold/test1.out           |   7 +
 tests/func_boolean_values/test1.xsl                |  50 +++
 .../xalan/xpath3/FuncBooleanValuesTests.java       |  62 ++++
 tests/org/apache/xalan/xslt3/Xsl3TestSuite1.java   |   3 +-
 28 files changed, 681 insertions(+), 539 deletions(-)

diff --git a/src/org/apache/xalan/templates/ElemAttribute.java b/src/org/apache/xalan/templates/ElemAttribute.java
index 5b25a4a9a..208c01eef 100644
--- a/src/org/apache/xalan/templates/ElemAttribute.java
+++ b/src/org/apache/xalan/templates/ElemAttribute.java
@@ -66,11 +66,17 @@ public class ElemAttribute extends ElemElement
      */
     protected Expression m_selectExpression = null;
     
-    // The following two variables are used, for performing fixupVariables
-    // action on certain XPath expression objects, within an object of this
-    // class.
-    private Vector fVars;    
-    private int fGlobalsSize;
+    /**
+     * This class field is used during, XPath.fixupVariables(..) action 
+     * as performed within object of this class.  
+     */    
+    private Vector m_vars;
+    
+    /**
+     * This class field is used during, XPath.fixupVariables(..) action 
+     * as performed within object of this class.  
+     */
+    private int m_globals_size;
 
   /**
    * Get an int constant identifying the type of element.
@@ -121,8 +127,8 @@ public class ElemAttribute extends ElemElement
     java.util.Vector vnames = cstate.getVariableNames();
     int golbalsSize = cstate.getGlobalsSize();
     
-    fVars = (java.util.Vector)(vnames.clone());
-    fGlobalsSize = golbalsSize; 
+    m_vars = (java.util.Vector)(vnames.clone());
+    m_globals_size = golbalsSize; 
   }
   
   /**
@@ -214,8 +220,8 @@ public class ElemAttribute extends ElemElement
             	  // to determine the value of an attribute for emitting to XSLT
             	  // transformation's output.
             	  
-                  if (fVars != null) {
-                     m_selectExpression.fixupVariables(fVars, fGlobalsSize);   
+                  if (m_vars != null) {
+                     m_selectExpression.fixupVariables(m_vars, m_globals_size);   
                   }
                   
                   XObject xpathEvalResult = m_selectExpression.execute(xctxt);
diff --git a/src/org/apache/xalan/templates/ElemCopyOf.java b/src/org/apache/xalan/templates/ElemCopyOf.java
index ce61167e9..5a5522672 100644
--- a/src/org/apache/xalan/templates/ElemCopyOf.java
+++ b/src/org/apache/xalan/templates/ElemCopyOf.java
@@ -80,11 +80,17 @@ public class ElemCopyOf extends ElemTemplateElement
    */
   private boolean m_isDot = false;
   
-  // The following two fields of this class, are used during 
-  // XPath.fixupVariables(..) action as performed within object of 
-  // this class.    
-  private Vector fVars;    
-  private int fGlobalsSize;
+  /**
+   * This class field is used during, XPath.fixupVariables(..) action 
+   * as performed within object of this class.  
+   */    
+  private Vector m_vars;
+  
+  /**
+   * This class field is used during, XPath.fixupVariables(..) action 
+   * as performed within object of this class.  
+   */
+  private int m_globals_size;
   
   public final static char SPACE_CHAR = ' ';
 
@@ -128,11 +134,11 @@ public class ElemCopyOf extends ElemTemplateElement
     
     java.util.Vector vnames = (sroot.getComposeState()).getVariableNames();
     
-    fVars = (Vector)(vnames.clone()); 
-    fGlobalsSize = (sroot.getComposeState()).getGlobalsSize();
+    m_vars = (Vector)(vnames.clone()); 
+    m_globals_size = (sroot.getComposeState()).getGlobalsSize();
 
     if (m_selectExpression != null) {
-        m_selectExpression.fixupVariables(vnames, fGlobalsSize);
+        m_selectExpression.fixupVariables(vnames, m_globals_size);
     }
   }
 
diff --git a/src/org/apache/xalan/templates/ElemSequence.java b/src/org/apache/xalan/templates/ElemSequence.java
index edd16bb94..b0465fe3c 100644
--- a/src/org/apache/xalan/templates/ElemSequence.java
+++ b/src/org/apache/xalan/templates/ElemSequence.java
@@ -78,11 +78,17 @@ public class ElemSequence extends ElemTemplateElement
    */
   public ElemSequence(){}
   
-  // The following two fields of this class, are used during 
-  // XPath.fixupVariables(..) action as performed within object of 
-  // this class.    
-  private Vector fVars;    
-  private int fGlobalsSize;
+  /**
+   * This class field is used during, XPath.fixupVariables(..) action 
+   * as performed within object of this class.  
+   */    
+  private Vector m_vars;
+  
+  /**
+   * This class field is used during, XPath.fixupVariables(..) action 
+   * as performed within object of this class.  
+   */
+  private int m_globals_size;
 
   /**
    * The value of the "select" attribute.
@@ -255,8 +261,8 @@ public class ElemSequence extends ElemTemplateElement
 
                    XPath varXPathObj = new XPath(varRefXPathExprStr, srcLocator, xctxt.getNamespaceContext(), 
                                                                                                          XPath.SELECT, null);
-                   if (fVars != null) {
-                      varXPathObj.fixupVariables(fVars, fGlobalsSize);  
+                   if (m_vars != null) {
+                      varXPathObj.fixupVariables(m_vars, m_globals_size);  
                    }
                    
                    XObject varEvalResult = varXPathObj.execute(xctxt, xctxt.getCurrentNode(), xctxt.getNamespaceContext());
@@ -271,8 +277,8 @@ public class ElemSequence extends ElemTemplateElement
                    XPath xpathIndexObj = new XPath(xpathIndexExprStr, srcLocator, xctxt.getNamespaceContext(), 
                                                                                                           XPath.SELECT, null);
                    
-                   if (fVars != null) {
-                      xpathIndexObj.fixupVariables(fVars, fGlobalsSize);  
+                   if (m_vars != null) {
+                      xpathIndexObj.fixupVariables(m_vars, m_globals_size);  
                    }
                    
                    XObject seqIndexEvalResult = xpathIndexObj.execute(xctxt, xctxt.getCurrentNode(), 
@@ -406,8 +412,8 @@ public class ElemSequence extends ElemTemplateElement
     
      java.util.Vector vnames = cstate.getVariableNames();
         
-     fVars = (Vector)vnames.clone();
-     fGlobalsSize = cstate.getGlobalsSize();
+     m_vars = (Vector)vnames.clone();
+     m_globals_size = cstate.getGlobalsSize();
         
      if (m_selectPattern != null) {
         m_selectPattern.fixupVariables(vnames, cstate.getGlobalsSize());
diff --git a/src/org/apache/xalan/templates/ElemValueOf.java b/src/org/apache/xalan/templates/ElemValueOf.java
index 998f6722f..20f45cee5 100644
--- a/src/org/apache/xalan/templates/ElemValueOf.java
+++ b/src/org/apache/xalan/templates/ElemValueOf.java
@@ -85,11 +85,17 @@ public class ElemValueOf extends ElemTemplateElement {
    */
   private boolean m_isDot = false;
   
-  // The following two fields of this class, are used during 
-  // XPath.fixupVariables(..) action as performed within object of 
-  // this class.    
-  private Vector fVars;    
-  private int fGlobalsSize;
+  /**
+   * This class field is used during, XPath.fixupVariables(..) action 
+   * as performed within object of this class.  
+   */    
+  private Vector m_vars;
+  
+  /**
+   * This class field is used during, XPath.fixupVariables(..) action 
+   * as performed within object of this class.  
+   */
+  private int m_globals_size;
 
   /**
    * Set the "select" attribute.
@@ -210,11 +216,11 @@ public class ElemValueOf extends ElemTemplateElement {
 
     java.util.Vector vnames = (sroot.getComposeState()).getVariableNames();
     
-    fVars = (Vector)(vnames.clone()); 
-    fGlobalsSize = (sroot.getComposeState()).getGlobalsSize();
+    m_vars = (Vector)(vnames.clone()); 
+    m_globals_size = (sroot.getComposeState()).getGlobalsSize();
 
     if (m_selectExpression != null) {
-        m_selectExpression.fixupVariables(vnames, fGlobalsSize);
+        m_selectExpression.fixupVariables(vnames, m_globals_size);
     }
   }
 
@@ -256,34 +262,7 @@ public class ElemValueOf extends ElemTemplateElement {
       transformer.getTraceManager().fireTraceEvent(this);
 
     try
-    {
-      // Optimize for "."
-      if (false && m_isDot && !transformer.getDebug())
-      {
-        int child = xctxt.getCurrentNode();
-        DTM dtm = xctxt.getDTM(child);
-
-        xctxt.pushCurrentNode(child);
-
-        if (m_disableOutputEscaping)
-          rth.processingInstruction(
-            javax.xml.transform.Result.PI_DISABLE_OUTPUT_ESCAPING, "");
-
-        try
-        {
-          dtm.dispatchCharactersEvents(child, rth, false);
-        }
-        finally
-        {
-          if (m_disableOutputEscaping)
-            rth.processingInstruction(
-              javax.xml.transform.Result.PI_ENABLE_OUTPUT_ESCAPING, "");
-
-          xctxt.popCurrentNode();
-        }
-      }
-      else
-      {
+    {      
         xctxt.pushNamespaceContext(this);
 
         int current = xctxt.getCurrentNode();
@@ -534,8 +513,8 @@ public class ElemValueOf extends ElemTemplateElement {
                            
                            XPath xpathObj = new XPath(varRefXPathExprStr, srcLocator, 
                                                                                  xctxt.getNamespaceContext(), XPath.SELECT, null);
-                           if (fVars != null) {
-                              xpathObj.fixupVariables(fVars, fGlobalsSize);                            
+                           if (m_vars != null) {
+                              xpathObj.fixupVariables(m_vars, m_globals_size);                            
                            }
                            
                            XObject varEvalResult = xpathObj.execute(xctxt, xctxt.getCurrentNode(), xctxt.getNamespaceContext());
@@ -549,8 +528,8 @@ public class ElemValueOf extends ElemTemplateElement {
                             
                            xpathObj = new XPath(xpathIndexExprStr, srcLocator, xctxt.getNamespaceContext(), XPath.SELECT, null);
                            
-                           if (fVars != null) {
-                              xpathObj.fixupVariables(fVars, fGlobalsSize);                            
+                           if (m_vars != null) {
+                              xpathObj.fixupVariables(m_vars, m_globals_size);                            
                            }
                            
                            XObject seqIndexEvalResult = xpathObj.execute(xctxt, xctxt.getCurrentNode(), 
@@ -624,7 +603,6 @@ public class ElemValueOf extends ElemTemplateElement {
           xctxt.popNamespaceContext();
           xctxt.popCurrentNodeAndExpression();
         }
-      }
     }
     catch (SAXException se)
     {
diff --git a/src/org/apache/xalan/templates/ElemVariable.java b/src/org/apache/xalan/templates/ElemVariable.java
index 41a9821fd..56a28c313 100644
--- a/src/org/apache/xalan/templates/ElemVariable.java
+++ b/src/org/apache/xalan/templates/ElemVariable.java
@@ -101,11 +101,17 @@ public class ElemVariable extends ElemTemplateElement
    */
   int m_frameSize = -1;
   
-  // The following two fields of this class, are used during 
-  // XPath.fixupVariables(..) action as performed within object of 
-  // this class.    
-  private Vector fVars;    
-  private int fGlobalsSize;
+  /**
+   * This class field is used during, XPath.fixupVariables(..) action 
+   * as performed within object of this class.  
+   */    
+  private Vector m_vars;
+  
+  /**
+   * This class field is used during, XPath.fixupVariables(..) action 
+   * as performed within object of this class.  
+   */
+  private int m_globals_size;
   
   /**
    * Sets the relative position of this variable within the stack frame (if local)
@@ -521,8 +527,8 @@ public class ElemVariable extends ElemTemplateElement
 
                    XPath varXPathObj = new XPath(varRefXPathExprStr, srcLocator, xctxt.getNamespaceContext(), 
                                                                                                     XPath.SELECT, null);
-                   if (fVars != null) {
-                      varXPathObj.fixupVariables(fVars, fGlobalsSize);  
+                   if (m_vars != null) {
+                      varXPathObj.fixupVariables(m_vars, m_globals_size);  
                    }
                    
                    XObject varEvalResult = varXPathObj.execute(xctxt, xctxt.getCurrentNode(), xctxt.getNamespaceContext());
@@ -537,8 +543,8 @@ public class ElemVariable extends ElemTemplateElement
                    XPath xpathIndexObj = new XPath(xpathIndexExprStr, srcLocator, xctxt.getNamespaceContext(), 
                                                                                                     XPath.SELECT, null);
                    
-                   if (fVars != null) {
-                      xpathIndexObj.fixupVariables(fVars, fGlobalsSize);  
+                   if (m_vars != null) {
+                      xpathIndexObj.fixupVariables(m_vars, m_globals_size);  
                    }
                    
                    XObject seqIndexEvalResult = xpathIndexObj.execute(xctxt, xctxt.getCurrentNode(), 
@@ -737,8 +743,8 @@ public class ElemVariable extends ElemTemplateElement
     // to the variable now being defined.
     java.util.Vector vnames = cstate.getVariableNames();
     
-    fVars = (Vector)vnames.clone();
-    fGlobalsSize = cstate.getGlobalsSize();
+    m_vars = (Vector)vnames.clone();
+    m_globals_size = cstate.getGlobalsSize();
     
     if(null != m_selectPattern)
       m_selectPattern.fixupVariables(vnames, cstate.getGlobalsSize());
diff --git a/src/org/apache/xpath/Expression.java b/src/org/apache/xpath/Expression.java
index 5c9d0f546..de1ed3345 100644
--- a/src/org/apache/xpath/Expression.java
+++ b/src/org/apache/xpath/Expression.java
@@ -74,18 +74,6 @@ public abstract class Expression implements java.io.Serializable, ExpressionNode
   {
     return false;
   }
-  
-//  /**
-//   * Set the location where this expression was built from.
-//   *
-//   *
-//   * @param locator the location where this expression was built from, may be
-//   *                null.
-//   */
-//  public void setSourceLocator(SourceLocator locator)
-//  {
-//    m_slocator = locator;
-//  }
 
   /**
    * Execute an expression in the XPath runtime context, and return the
diff --git a/src/org/apache/xpath/XPath.java b/src/org/apache/xpath/XPath.java
index da800d628..0ab46f6bf 100644
--- a/src/org/apache/xpath/XPath.java
+++ b/src/org/apache/xpath/XPath.java
@@ -15,9 +15,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-/*
- * $Id$
- */
 package org.apache.xpath;
 
 import java.io.Serializable;
@@ -50,16 +47,18 @@ import org.apache.xpath.res.XPATHErrorResources;
 import xml.xpath31.processor.types.XSNumericType;
 
 /**
- * The XPath class wraps an expression object and provides general services 
- * for execution of that expression.
+ * This class wraps an XPath expression object and provides 
+ * common services for evaluation of that expression.
+ * 
  * @xsl.usage advanced
  */
 public class XPath implements Serializable, ExpressionOwner
 {
   static final long serialVersionUID = 3976493477939110553L;
 
-  /** The top of the expression tree. 
-   *  @serial */
+  /** 
+   * The top of XPath expression tree. 
+   */
   private Expression m_mainExp;
   
   /**
@@ -67,23 +66,29 @@ public class XPath implements Serializable, ExpressionOwner
    */
   private transient FunctionTable m_funcTable = null;
   
-  // The following two fields of this class, are used during 
-  // XPath.fixupVariables(..) action as performed within object of 
-  // this class.    
-  private Vector fVars;    
-  private int fGlobalsSize;
+  /**
+   * This class field is used during, XPath.fixupVariables(..) action 
+   * as performed within object of this class.  
+   */    
+  private Vector m_vars;
+  
+  /**
+   * This class field is used during, XPath.fixupVariables(..) action 
+   * as performed within object of this class.  
+   */
+  private int m_globals_size;
   
   /**
-   * This class field, is used when evaluating an 
+   * This class field, is used while evaluating an 
    * XPath arrow operator, "=>".
    */
-  private String fArrowOpRemainingXPathExprStr = null;
+  private String m_arrowop_remaining_xpath_expr_str = null;
   
   /**
-   * This variable being true denotes, that this XPath expression
-   * is for quantified expression's satisfies clause. 
+   * This class field with boolean true value denotes, that this XPath 
+   * expression corresponds to quantified expression's satisfies clause. 
    */
-  private boolean fIsQuantifiedExpr;
+  private boolean m_is_quantified_expr;
 
   /**
    * initial the function table
@@ -115,8 +120,8 @@ public class XPath implements Serializable, ExpressionOwner
    */
   public void fixupVariables(java.util.Vector vars, int globalsSize)
   {
-    fVars = (Vector)(vars.clone());
-    fGlobalsSize = globalsSize;
+    m_vars = (Vector)(vars.clone());
+    m_globals_size = globalsSize;
     
     m_mainExp.fixupVariables(vars, globalsSize);
   }
@@ -196,7 +201,7 @@ public class XPath implements Serializable, ExpressionOwner
     
     if (SELECT == type) {
       parser.initXPath(compiler, exprString, prefixResolver, false);
-      fArrowOpRemainingXPathExprStr = parser.getArrowOpRemainingXPathExprStr();
+      m_arrowop_remaining_xpath_expr_str = parser.getArrowOpRemainingXPathExprStr();
     }
     else if (MATCH == type)
       parser.initMatchPattern(compiler, exprString, prefixResolver);
@@ -205,7 +210,7 @@ public class XPath implements Serializable, ExpressionOwner
 
     Expression expr = compiler.compile(0);
     if (expr instanceof ArrowOp) {
-       ((ArrowOp)expr).setArrowOpRemainingXPathExprStr(fArrowOpRemainingXPathExprStr);
+       ((ArrowOp)expr).setArrowOpRemainingXPathExprStr(m_arrowop_remaining_xpath_expr_str);
     }
     
     this.setExpression(expr);
@@ -248,7 +253,7 @@ public class XPath implements Serializable, ExpressionOwner
     
     if (SELECT == type) {
       parser.initXPath(compiler, exprString, prefixResolver, false);
-      fArrowOpRemainingXPathExprStr = parser.getArrowOpRemainingXPathExprStr();
+      m_arrowop_remaining_xpath_expr_str = parser.getArrowOpRemainingXPathExprStr();
     }
     else if (MATCH == type)
       parser.initMatchPattern(compiler, exprString, prefixResolver);
@@ -259,7 +264,7 @@ public class XPath implements Serializable, ExpressionOwner
 
     Expression expr = compiler.compile(0);
     if (expr instanceof ArrowOp) {
-      ((ArrowOp)expr).setArrowOpRemainingXPathExprStr(fArrowOpRemainingXPathExprStr);
+      ((ArrowOp)expr).setArrowOpRemainingXPathExprStr(m_arrowop_remaining_xpath_expr_str);
     }
 
     this.setExpression(expr);
@@ -388,161 +393,17 @@ public class XPath implements Serializable, ExpressionOwner
             throws javax.xml.transform.TransformerException
   {
 
-    xctxt.pushNamespaceContext(namespaceContext);
+	  XObject result = null;
+	  
+	  xctxt.pushNamespaceContext(namespaceContext);
 
-    xctxt.pushCurrentNodeAndExpression(contextNode, contextNode);
-    
-    SourceLocator srcLocator = xctxt.getSAXLocator(); 
+	  xctxt.pushCurrentNodeAndExpression(contextNode, contextNode);
 
-    XObject xobj = null;
-    
-    boolean isProcessAsNodeset = true;
-    
-    if (m_mainExp instanceof LocPathIterator) {
-        LocPathIterator locPathIterator = (LocPathIterator)m_mainExp;
-        
-        DTMIterator dtmIter = null;                     
-        try {
-           dtmIter = locPathIterator.asIterator(xctxt, contextNode);
-        }
-        catch (ClassCastException ex) {
-           isProcessAsNodeset = false;
-        }
-    }
+	  SourceLocator srcLocator = xctxt.getSAXLocator();
 
-    try {
-       if (isProcessAsNodeset) {
-          if (m_mainExp instanceof Function) {
-             xobj = ((Function)m_mainExp).execute(xctxt); 
-          }
-          else {
-             xobj = m_mainExp.execute(xctxt);
-          }
-       }
-       else {
-          String xpathPatternStr = getPatternString();
-               
-          if (xpathPatternStr.startsWith("$") && xpathPatternStr.contains("[") && 
-                                                                            xpathPatternStr.endsWith("]")) {              
-        	 // Here we handle the case, when an XPath expression has syntax of type $varName[expr], 
-             // for example $varName[1], $varName[$idx], $varName[funcCall(arg)] etc, and $varName 
-             // resolves to a 'ResultSequence' object.
-                   
-             String varRefXPathExprStr = "$" + xpathPatternStr.substring(1, xpathPatternStr.indexOf('['));
-             String xpathIndexExprStr = xpathPatternStr.substring(xpathPatternStr.indexOf('[') + 1, 
-                                                                                          xpathPatternStr.indexOf(']'));
-             ElemTemplateElement elemTemplateElement = (ElemTemplateElement)xctxt.getNamespaceContext();
-             List<XMLNSDecl> prefixTable = null;
-             if (elemTemplateElement != null) {
-                prefixTable = (List<XMLNSDecl>)elemTemplateElement.getPrefixTable();
-             }
-                  
-             // Evaluate the, variable reference XPath expression
-             if (prefixTable != null) {
-                varRefXPathExprStr = XslTransformEvaluationHelper.replaceNsUrisWithPrefixesOnXPathStr(
-                                                                                                 varRefXPathExprStr, 
-                                                                                                 prefixTable);
-             }
-                  
-             XPath xpathObj = new XPath(varRefXPathExprStr, srcLocator, 
-                                                                   xctxt.getNamespaceContext(), XPath.SELECT, null);            
-             if (fVars != null) {
-                xpathObj.fixupVariables(fVars, fGlobalsSize);  
-             }
-                  
-             XObject varEvalResult = xpathObj.execute(xctxt, xctxt.getCurrentNode(), xctxt.getNamespaceContext());
-                  
-             // Evaluate the, xdm sequence index XPath expression
-             if (prefixTable != null) {
-                xpathIndexExprStr = XslTransformEvaluationHelper.replaceNsUrisWithPrefixesOnXPathStr(
-                                                                                                xpathIndexExprStr, 
-                                                                                                prefixTable);
-             }
-                  
-             xpathObj = new XPath(xpathIndexExprStr, srcLocator, xctxt.getNamespaceContext(), XPath.SELECT, null);
-                  
-             if (fVars != null) {
-                xpathObj.fixupVariables(fVars, fGlobalsSize);  
-             }
-                  
-             XObject seqIndexEvalResult = xpathObj.execute(xctxt, xctxt.getCurrentNode(), 
-                                                                                    xctxt.getNamespaceContext());
-             if (varEvalResult instanceof ResultSequence) {
-                ResultSequence resultSeq = (ResultSequence)varEvalResult;
-                     
-                if (seqIndexEvalResult instanceof XNumber) {
-                   double dValIndex = ((XNumber)seqIndexEvalResult).num();
-                   if (dValIndex == (int)dValIndex) {
-                      xobj = resultSeq.item((int)dValIndex - 1);
-                   }
-                   else {
-                      throw new javax.xml.transform.TransformerException("XPTY0004 : an index value used with an xdm "
-                                                                                                      + "sequence reference, is not an integer.", 
-                                                                                                            srcLocator); 
-                   }  
-                }
-                else if (seqIndexEvalResult instanceof XSNumericType) {
-                        String indexStrVal = ((XSNumericType)seqIndexEvalResult).stringValue();
-                        double dValIndex = (Double.valueOf(indexStrVal)).doubleValue();
-                        if (dValIndex == (int)dValIndex) {
-                           xobj = resultSeq.item((int)dValIndex - 1);                                  
-                        }
-                        else {
-                           throw new javax.xml.transform.TransformerException("XPTY0004 : an index value used with an xdm "
-                                                                                                + "sequence reference, is not an integer.", 
-                                                                                                     srcLocator); 
-                        } 
-                }
-                else {
-                        throw new javax.xml.transform.TransformerException("XPTY0004 : an index value used with an xdm sequence "
-                                                                                               + "reference, is not numeric.", srcLocator);  
-                }
-              }          
-            }  
-          }
-        }
-        catch (TransformerException te)
-        {
-          te.setLocator(this.getLocator());
-          ErrorListener el = xctxt.getErrorListener();
-          if(null != el && !fIsQuantifiedExpr)
-          {
-            el.error(te);
-          }
-          else
-            throw te;
-        }
-    catch (Exception e)
-    {
-       while (e instanceof org.apache.xml.utils.WrappedRuntimeException)
-       {
-          e = ((org.apache.xml.utils.WrappedRuntimeException) e).getException();
-       }
-    
-       String msg = e.getMessage();
-          
-       if (msg == null || msg.length() == 0) {
-          msg = XSLMessages.createXPATHMessage(
-                                     XPATHErrorResources.ER_XPATH_ERROR, null);
-         
-       }  
-       TransformerException te = new TransformerException(msg, getLocator(), e);
-       ErrorListener el = xctxt.getErrorListener();
-       if(null != el)
-       {
-          el.fatalError(te);
-       }
-       else
-          throw te;
-    }
-    finally
-    {
-       xctxt.popNamespaceContext();
-    
-       xctxt.popCurrentNodeAndExpression();
-    }
+	  result = evaluateXPathExpr(xctxt, contextNode, srcLocator);
 
-    return xobj;
+	  return result;
   }
   
   /**
@@ -800,15 +661,169 @@ public class XPath implements Serializable, ExpressionOwner
   public static final double MATCH_SCORE_OTHER = 0.5;
 
   public String getArrowOpRemainingXPathExprStr() {
-	 return fArrowOpRemainingXPathExprStr;
+	 return m_arrowop_remaining_xpath_expr_str;
   }
 
   public void setArrowOpRemainingXPathExprStr(String arrowOpRemainingXPathExprStr) {
-	 this.fArrowOpRemainingXPathExprStr = arrowOpRemainingXPathExprStr;
+	 this.m_arrowop_remaining_xpath_expr_str = arrowOpRemainingXPathExprStr;
   }
 
   public void setIsQuantifiedExpr(boolean isQuantifiedExpr) {	
-	 this.fIsQuantifiedExpr = isQuantifiedExpr;
+	 this.m_is_quantified_expr = isQuantifiedExpr;
+  }
+  
+  /**
+   * Evaluate an XPath expression, to produce an xdm result item.
+   */
+  private XObject evaluateXPathExpr(XPathContext xctxt, int contextNode, SourceLocator srcLocator)
+		                                                              throws TransformerException {
+
+	  XObject result = null;
+
+	  boolean isProcessAsNodeset = true;
+
+	  if (m_mainExp instanceof LocPathIterator) {
+		  LocPathIterator locPathIterator = (LocPathIterator)m_mainExp;
+
+		  DTMIterator dtmIter = null;                     
+		  try {
+			  dtmIter = locPathIterator.asIterator(xctxt, contextNode);
+		  }
+		  catch (ClassCastException ex) {
+			  isProcessAsNodeset = false;
+		  }
+	  }
+
+	  try {    	
+		  if (isProcessAsNodeset) {
+			  if (m_mainExp instanceof Function) {
+				  result = ((Function)m_mainExp).execute(xctxt); 
+			  }
+			  else {
+				  result = m_mainExp.execute(xctxt);
+			  }
+		  }
+		  else {
+			  String xpathPatternStr = getPatternString();
+
+			  if (xpathPatternStr.startsWith("$") && xpathPatternStr.contains("[") && xpathPatternStr.endsWith("]")) {
+				  /**
+				   * Here we handle the case, when an XPath expression has syntax of type $varName[expr], 
+				   * for example $varName[1], $varName[$idx], $varName[funcCall(arg)] etc, and $varName 
+				   * resolves to a 'ResultSequence' object.
+				   */
+				  String varRefXPathExprStr = "$" + xpathPatternStr.substring(1, xpathPatternStr.indexOf('['));
+				  String xpathIndexExprStr = xpathPatternStr.substring(xpathPatternStr.indexOf('[') + 1, 
+						                                                         xpathPatternStr.indexOf(']'));
+				  ElemTemplateElement elemTemplateElement = (ElemTemplateElement)xctxt.getNamespaceContext();
+				  List<XMLNSDecl> prefixTable = null;
+				  if (elemTemplateElement != null) {
+					  prefixTable = (List<XMLNSDecl>)elemTemplateElement.getPrefixTable();
+				  }
+
+				  // Evaluate the, variable reference XPath expression
+				  if (prefixTable != null) {
+					  varRefXPathExprStr = XslTransformEvaluationHelper.replaceNsUrisWithPrefixesOnXPathStr(
+							                                                             varRefXPathExprStr, 
+							                                                             prefixTable);
+				  }
+
+				  XPath xpathObj = new XPath(varRefXPathExprStr, srcLocator, xctxt.getNamespaceContext(), XPath.SELECT, null);            
+				  if (m_vars != null) {
+					  xpathObj.fixupVariables(m_vars, m_globals_size);  
+				  }
+
+				  XObject varEvalResult = xpathObj.execute(xctxt, xctxt.getCurrentNode(), xctxt.getNamespaceContext());
+
+				  // Evaluate the, xdm sequence index XPath expression
+				  if (prefixTable != null) {
+					  xpathIndexExprStr = XslTransformEvaluationHelper.replaceNsUrisWithPrefixesOnXPathStr(
+							                                                         xpathIndexExprStr, 
+							                                                         prefixTable);
+				  }
+
+				  xpathObj = new XPath(xpathIndexExprStr, srcLocator, xctxt.getNamespaceContext(), XPath.SELECT, null);
+
+				  if (m_vars != null) {
+					  xpathObj.fixupVariables(m_vars, m_globals_size);  
+				  }
+
+				  XObject seqIndexEvalResult = xpathObj.execute(xctxt, xctxt.getCurrentNode(), xctxt.getNamespaceContext());
+				  if (varEvalResult instanceof ResultSequence) {
+					  ResultSequence resultSeq = (ResultSequence)varEvalResult;
+
+					  if (seqIndexEvalResult instanceof XNumber) {
+						  double dValIndex = ((XNumber)seqIndexEvalResult).num();
+						  if (dValIndex == (int)dValIndex) {
+							  result = resultSeq.item((int)dValIndex - 1);
+						  }
+						  else {
+							  throw new javax.xml.transform.TransformerException("XPTY0004 : an index value used with an xdm "
+									                                                               + "sequence reference, is not an integer.", 
+									                                                               srcLocator); 
+						  }  
+					  }
+					  else if (seqIndexEvalResult instanceof XSNumericType) {
+						  String indexStrVal = ((XSNumericType)seqIndexEvalResult).stringValue();
+						  double dValIndex = (Double.valueOf(indexStrVal)).doubleValue();
+						  if (dValIndex == (int)dValIndex) {
+							  result = resultSeq.item((int)dValIndex - 1);                                  
+						  }
+						  else {
+							  throw new javax.xml.transform.TransformerException("XPTY0004 : an index value used with an xdm "
+									                                                               + "sequence reference, is not an integer.", 
+									                                                               srcLocator); 
+						  } 
+					  }
+					  else {
+						  throw new javax.xml.transform.TransformerException("XPTY0004 : an index value used with an xdm sequence "
+								                                                               + "reference, is not numeric.", srcLocator);  
+					  }
+				  }          
+			  }  
+		  }
+	  }
+	  catch (TransformerException te)
+	  {
+		  te.setLocator(this.getLocator());
+		  ErrorListener el = xctxt.getErrorListener();
+		  if(null != el && !m_is_quantified_expr)
+		  {
+			  el.error(te);
+		  }
+		  else
+			  throw te;
+	  }
+	  catch (Exception e)
+	  {
+		  while (e instanceof org.apache.xml.utils.WrappedRuntimeException)
+		  {
+			  e = ((org.apache.xml.utils.WrappedRuntimeException) e).getException();
+		  }
+
+		  String msg = e.getMessage();
+
+		  if (msg == null || msg.length() == 0) {
+			  msg = XSLMessages.createXPATHMessage(XPATHErrorResources.ER_XPATH_ERROR, null);
+
+		  }  
+		  TransformerException te = new TransformerException(msg, getLocator(), e);
+		  ErrorListener el = xctxt.getErrorListener();
+		  if(null != el)
+		  {
+			  el.fatalError(te);
+		  }
+		  else
+			  throw te;
+	  }
+	  finally
+	  {
+		  xctxt.popNamespaceContext();
+
+		  xctxt.popCurrentNodeAndExpression();
+	  }
+
+	  return result;
   }
 
 }
diff --git a/src/org/apache/xpath/axes/FilterExprWalker.java b/src/org/apache/xpath/axes/FilterExprWalker.java
index 38e7ce409..8f3dc417c 100644
--- a/src/org/apache/xpath/axes/FilterExprWalker.java
+++ b/src/org/apache/xpath/axes/FilterExprWalker.java
@@ -75,10 +75,8 @@ public class FilterExprWalker extends AxesWalker
     case OpCodes.OP_VARIABLE :
       m_expr = compiler.compile(opPos);
       m_expr.exprSetParent(this);
-      //if((OpCodes.OP_FUNCTION == stepType) && (m_expr instanceof org.apache.xalan.templates.FuncKey))
       if(m_expr instanceof org.apache.xpath.operations.Variable)
       {
-      	// hack/temp workaround
       	m_canDetachNodeset = false;
       }
       break;
@@ -86,20 +84,6 @@ public class FilterExprWalker extends AxesWalker
       m_expr = compiler.compile(opPos + 2);
       m_expr.exprSetParent(this);
     }
-//    if(m_expr instanceof WalkingIterator)
-//    {
-//      WalkingIterator wi = (WalkingIterator)m_expr;
-//      if(wi.getFirstWalker() instanceof FilterExprWalker)
-//      {
-//      	FilterExprWalker fw = (FilterExprWalker)wi.getFirstWalker();
-//      	if(null == fw.getNextWalker())
-//      	{
-//      		m_expr = fw.m_expr;
-//      		m_expr.exprSetParent(this);
-//      	}
-//      }
-//      		
-//    }
   }
   
   /**
@@ -214,8 +198,9 @@ public class FilterExprWalker extends AxesWalker
     return m_exprObj.getLength();
   }
   
-  /** The contained expression. Should be non-null.
-   *  @serial   */
+  /** 
+   * The contained expression. Should be non-null.   
+   */
   private Expression m_expr;
 
   /** The result of executing m_expr.  Needs to be deep cloned on clone op.  */
diff --git a/src/org/apache/xpath/axes/WalkerFactory.java b/src/org/apache/xpath/axes/WalkerFactory.java
index 3da3b81f6..1bf9ebc80 100644
--- a/src/org/apache/xpath/axes/WalkerFactory.java
+++ b/src/org/apache/xpath/axes/WalkerFactory.java
@@ -268,10 +268,6 @@ public class WalkerFactory
       }
       else
       {
-//        if (DEBUG_ITERATOR_CREATION)
-//          diagnoseIterator("MatchPatternIterator", analysis, compiler);
-//
-//        return new MatchPatternIterator(compiler, opPos, analysis);
         if (DEBUG_ITERATOR_CREATION)
           diagnoseIterator("WalkingIteratorSorted", analysis, compiler);
 
diff --git a/src/org/apache/xpath/axes/WalkingIterator.java b/src/org/apache/xpath/axes/WalkingIterator.java
index 61d48dcef..10765f349 100644
--- a/src/org/apache/xpath/axes/WalkingIterator.java
+++ b/src/org/apache/xpath/axes/WalkingIterator.java
@@ -32,7 +32,6 @@ import org.apache.xpath.compiler.OpMap;
 /**
  * Location path iterator that uses Walkers.
  */
-
 public class WalkingIterator extends LocPathIterator implements ExpressionOwner
 {
     static final long serialVersionUID = 9110225941815665906L;
@@ -112,9 +111,7 @@ public class WalkingIterator extends LocPathIterator implements ExpressionOwner
   {
 
     WalkingIterator clone = (WalkingIterator) super.clone();
-
-    //    clone.m_varStackPos = this.m_varStackPos;
-    //    clone.m_varStackContext = this.m_varStackContext;
+    
     if (null != m_firstWalker)
     {
       clone.m_firstWalker = m_firstWalker.cloneDeep(clone, null);
diff --git a/src/org/apache/xpath/compiler/Compiler.java b/src/org/apache/xpath/compiler/Compiler.java
index 89ccb208f..e51f20949 100644
--- a/src/org/apache/xpath/compiler/Compiler.java
+++ b/src/org/apache/xpath/compiler/Compiler.java
@@ -151,7 +151,7 @@ public class Compiler extends OpMap
     int op = getOp(opPos);
 
     Expression expr = null;
-    // System.out.println(getPatternString()+"op: "+op);
+
     switch (op)
     {
     case OpCodes.OP_XPATH :
@@ -232,8 +232,6 @@ public class Compiler extends OpMap
       expr = div(opPos); break;
     case OpCodes.OP_MOD :
       expr = mod(opPos); break;
-//    case OpCodes.OP_QUO :
-//      expr = quo(opPos); break;
     case OpCodes.OP_NEG :
       expr = neg(opPos); break;
     case OpCodes.OP_STRING :
@@ -273,15 +271,12 @@ public class Compiler extends OpMap
     case OpCodes.OP_NAMED_FUNCTION_REFERENCE :
       expr = namedFunctionReference(opPos); break;	
     case OpCodes.OP_QUO:
-      error(XPATHErrorResources.ER_UNKNOWN_OPCODE,
-            new Object[]{ "quo" });  //"ERROR! Unknown op code: "+m_opMap[opPos]);
+      error(XPATHErrorResources.ER_UNKNOWN_OPCODE, new Object[]{ "quo" });
       break;
     default :
       error(XPATHErrorResources.ER_UNKNOWN_OPCODE,
-            new Object[]{ Integer.toString(getOp(opPos)) });  //"ERROR! Unknown op code: "+m_opMap[opPos]);
+            new Object[]{ Integer.toString(getOp(opPos)) });
     }
-//    if(null != expr)
-//      expr.setSourceLocator(m_locator);
     
     return expr;
   }
diff --git a/src/org/apache/xpath/compiler/Keywords.java b/src/org/apache/xpath/compiler/Keywords.java
index 43d2ad4b1..efb958a09 100644
--- a/src/org/apache/xpath/compiler/Keywords.java
+++ b/src/org/apache/xpath/compiler/Keywords.java
@@ -24,7 +24,7 @@ import java.util.Hashtable;
 
 /**
  * Table of strings to operation code lookups
- * to support implementation of XPath 3.1.
+ * to support implementation of XPath.
  * 
  * @author Scott Boag <sc...@us.ibm.com>
  * @author Gary L Peskin <ga...@apache.org>
@@ -54,8 +54,7 @@ public class Keywords
   private static final String FROM_ANCESTORS_STRING = "ancestor";
 
   /** ancestor-or-self axes string. */
-  private static final String FROM_ANCESTORS_OR_SELF_STRING =
-    "ancestor-or-self";
+  private static final String FROM_ANCESTORS_OR_SELF_STRING = "ancestor-or-self";
 
   /** attribute axes string. */
   private static final String FROM_ATTRIBUTES_STRING = "attribute";
@@ -67,15 +66,13 @@ public class Keywords
   private static final String FROM_DESCENDANTS_STRING = "descendant";
 
   /** ancestor axes string. */
-  private static final String FROM_DESCENDANTS_OR_SELF_STRING =
-    "descendant-or-self";
+  private static final String FROM_DESCENDANTS_OR_SELF_STRING = "descendant-or-self";
 
   /** following axes string. */
   private static final String FROM_FOLLOWING_STRING = "following";
 
   /** following-sibling axes string. */
-  private static final String FROM_FOLLOWING_SIBLINGS_STRING =
-    "following-sibling";
+  private static final String FROM_FOLLOWING_SIBLINGS_STRING = "following-sibling";
 
   /** parent axes string. */
   private static final String FROM_PARENT_STRING = "parent";
@@ -84,8 +81,7 @@ public class Keywords
   private static final String FROM_PRECEDING_STRING = "preceding";
 
   /** preceding-sibling axes string. */
-  private static final String FROM_PRECEDING_SIBLINGS_STRING =
-    "preceding-sibling";
+  private static final String FROM_PRECEDING_SIBLINGS_STRING = "preceding-sibling";
 
   /** self axes string. */
   private static final String FROM_SELF_STRING = "self";
@@ -151,7 +147,7 @@ public class Keywords
   public static final String FUNC_FALSE_STRING = "false";
 
   /**
-   * boolean function string. we use this same configuration, 
+   * boolean function string. we use this same keyword string 
    * for XML Schema data type xs:boolean as well.
    */
   public static final String FUNC_BOOLEAN_STRING = "boolean";
@@ -190,8 +186,7 @@ public class Keywords
   public static final String FUNC_CONTAINS_STRING = "contains";
 
   /** substring-before function string. */
-  public static final String FUNC_SUBSTRING_BEFORE_STRING =
-    "substring-before";
+  public static final String FUNC_SUBSTRING_BEFORE_STRING = "substring-before";
 
   /** substring-after function string. */
   public static final String FUNC_SUBSTRING_AFTER_STRING = "substring-after";
@@ -209,12 +204,10 @@ public class Keywords
   public static final String FUNC_SYSTEM_PROPERTY_STRING = "system-property";
 
   /** function-available function string (XSLT). */
-  public static final String FUNC_EXT_FUNCTION_AVAILABLE_STRING =
-    "function-available";
+  public static final String FUNC_EXT_FUNCTION_AVAILABLE_STRING = "function-available";
 
   /** element-available function string (XSLT). */
-  public static final String FUNC_EXT_ELEM_AVAILABLE_STRING =
-    "element-available";
+  public static final String FUNC_EXT_ELEM_AVAILABLE_STRING = "element-available";
 
   /** substring function string. */
   public static final String FUNC_SUBSTRING_STRING = "substring";
@@ -223,8 +216,7 @@ public class Keywords
   public static final String FUNC_STRING_LENGTH_STRING = "string-length";
 
   /** unparsed-entity-uri function string (XSLT). */
-  public static final String FUNC_UNPARSED_ENTITY_URI_STRING =
-    "unparsed-entity-uri";
+  public static final String FUNC_UNPARSED_ENTITY_URI_STRING = "unparsed-entity-uri";
   
   /** matches function string. */
   public static final String FUNC_MATCHES_STRING = "matches";
@@ -756,18 +748,18 @@ public class Keywords
   }
   
   static Object getAxisName(String key){
-          return m_axisnames.get(key);
+	  return m_axisnames.get(key);
   }
-  
+
   static Object lookupNodeTest(String key){
-          return m_nodetests.get(key);
+	  return m_nodetests.get(key);
   }
-  
+
   static Object getKeyWord(String key){
-          return m_keywords.get(key);
+	  return m_keywords.get(key);
   }
-  
+
   static Object getNodeType(String key){
-          return m_nodetypes.get(key);
+	  return m_nodetypes.get(key);
   }      
 }
diff --git a/src/org/apache/xpath/compiler/XPathParser.java b/src/org/apache/xpath/compiler/XPathParser.java
index 29a3ab966..a52936d6d 100644
--- a/src/org/apache/xpath/compiler/XPathParser.java
+++ b/src/org/apache/xpath/compiler/XPathParser.java
@@ -3091,8 +3091,6 @@ public class XPathParser
     {
       if (tokenIs('['))
       {
-
-        // int locationPathOpPos = opPos;
         insertOp(opPos, 2, OpCodes.OP_LOCATIONPATH);
 
         while (tokenIs('['))
@@ -3113,14 +3111,7 @@ public class XPathParser
     }
 
     return filterMatch;
-
-    /*
-     * if(tokenIs('['))
-     * {
-     *   Predicate();
-     *   m_ops.m_opMap[opPos + OpMap.MAPINDEX_LENGTH] = m_ops.m_opMap[OpMap.MAPINDEX_LENGTH] - opPos;
-     * }
-     */
+    
   }
 
   /**
@@ -4066,8 +4057,7 @@ public class XPathParser
 
       if (null == nodeTestOp)
       {
-        error(XPATHErrorResources.ER_UNKNOWN_NODETYPE,
-              new Object[]{ m_token });  //"Unknown nodetype: "+m_token);
+        error(XPATHErrorResources.ER_UNKNOWN_NODETYPE, new Object[]{ m_token });
       }
       else
       {
@@ -4151,10 +4141,9 @@ public class XPathParser
   }
 
   /**
-   *
+   * 
    * Predicate ::= '[' PredicateExpr ']'
    *
-   *
    * @throws javax.xml.transform.TransformerException
    */
   protected void Predicate() throws javax.xml.transform.TransformerException
@@ -4162,19 +4151,18 @@ public class XPathParser
 
     if (tokenIs('['))
     {
-      m_isXPathPredicateParsingActive = true;      
-      nextToken();
-      PredicateExpr();
-      consumeExpected(']');      
-      m_isXPathPredicateParsingActive = false;
+    	m_isXPathPredicateParsingActive = true;      
+    	nextToken();
+    	PredicateExpr();
+    	consumeExpected(']');      
+    	m_isXPathPredicateParsingActive = false;
     }
   }
 
   /**
-   *
+   * 
    * PredicateExpr ::= Expr
    *
-   *
    * @throws javax.xml.transform.TransformerException
    */
   protected void PredicateExpr() throws javax.xml.transform.TransformerException
diff --git a/src/org/apache/xpath/composite/XPathArrayConstructor.java b/src/org/apache/xpath/composite/XPathArrayConstructor.java
index afa8ece77..596c95fc5 100644
--- a/src/org/apache/xpath/composite/XPathArrayConstructor.java
+++ b/src/org/apache/xpath/composite/XPathArrayConstructor.java
@@ -43,9 +43,9 @@ import org.apache.xpath.objects.XPathArray;
 
 import xml.xpath31.processor.types.XSNumericType;
 
-/*
- * Xalan-J's xpath parser, constructs an object of this class 
- * to help implement XPath 3.1 arrays.
+/**
+ * This class implements and evaluates XPath 3.1 literal 
+ * array constructor expressions.
  * 
  * @author Mukul Gandhi <mu...@apache.org>
  * 
@@ -59,11 +59,17 @@ public class XPathArrayConstructor extends Expression {
 	
 	private boolean m_IsEmptyArray = false;
     
-    // The following two fields of this class, are used during 
-    // XPath.fixupVariables(..) action as performed within object of 
-    // this class.    
-    private Vector m_vars;    
-    private int m_globals_size;
+	/**
+	 * This class field is used during, XPath.fixupVariables(..) action 
+	 * as performed within object of this class.  
+	 */    
+	private Vector m_vars;
+	  
+	/**
+	 * This class field is used during, XPath.fixupVariables(..) action 
+	 * as performed within object of this class.  
+	 */
+	private int m_globals_size;
 
     @Override
     public XObject execute(XPathContext xctxt) throws TransformerException {
diff --git a/src/org/apache/xpath/composite/XPathMapConstructor.java b/src/org/apache/xpath/composite/XPathMapConstructor.java
index d1230c60e..194b18944 100644
--- a/src/org/apache/xpath/composite/XPathMapConstructor.java
+++ b/src/org/apache/xpath/composite/XPathMapConstructor.java
@@ -52,10 +52,8 @@ import xml.xpath31.processor.types.XSNumericType;
 import xml.xpath31.processor.types.XSString;
 
 /**
- * Xalan-J's XPath parser, constructs an object of this class, 
- * to produce run-time representation of an XPath map expression.
- * 
- * Ref: https://www.w3.org/TR/xpath-31/#id-maps
+ * This class implements and evaluates XPath 3.1 map 
+ * expressions.
  * 
  * @author Mukul Gandhi <mu...@apache.org>
  * 
@@ -65,14 +63,23 @@ public class XPathMapConstructor extends Expression {
     
 	private static final long serialVersionUID = 2664427126053000318L;
 	
-	// Variable reference, denoting an native run-time map
-	private Map<String, String> fMapVar = new HashMap<String, String>();
+	/**
+     * This class field, serves as native run-time storage for 
+     * xpath maps.
+	 */
+	private Map<String, String> m_native_map = new HashMap<String, String>();
 	
-	// The following two fields of this class, are used during 
-    // XPath.fixupVariables(..) action as performed within object of 
-    // this class.    
-    private Vector fVars;    
-    private int fGlobalsSize;
+	/**
+	 * This class field is used during, XPath.fixupVariables(..) action 
+	 * as performed within object of this class.  
+	 */    
+	private Vector m_vars;
+	  
+	/**
+	 * This class field is used during, XPath.fixupVariables(..) action 
+	 * as performed within object of this class.  
+	 */
+	private int m_globals_size;
     
     private String KEY = "key";
     private String VALUE = "value";
@@ -92,7 +99,7 @@ public class XPathMapConstructor extends Expression {
             prefixTable = (List<XMLNSDecl>)elemTemplateElement.getPrefixTable();
         }
         
-        Set<Entry<String, String>> mapEntrySet = fMapVar.entrySet();
+        Set<Entry<String, String>> mapEntrySet = m_native_map.entrySet();
         Iterator<Entry<String, String>> mapIter = mapEntrySet.iterator();
         while (mapIter.hasNext()) {
            Entry<String, String> mapEntry = mapIter.next();
@@ -126,16 +133,16 @@ public class XPathMapConstructor extends Expression {
 
     @Override
     public void fixupVariables(Vector vars, int globalsSize) {
-        fVars = (Vector)(vars.clone());
-        fGlobalsSize = globalsSize;
+        m_vars = (Vector)(vars.clone());
+        m_globals_size = globalsSize;
     }
 
 	public Map<String, String> getNativeMap() {
-		return fMapVar;
+		return m_native_map;
 	}
 
 	public void setNativeMap(Map<String, String> map) {
-		this.fMapVar = map;
+		this.m_native_map = map;
 	}
 	
     @Override
@@ -160,8 +167,8 @@ public class XPathMapConstructor extends Expression {
     	SourceLocator srcLocator = xctxt.getSAXLocator();
     	
     	XPath xpathObj = new XPath(xpathExprStr, srcLocator, xctxt.getNamespaceContext(), XPath.SELECT, null);
-        if (fVars != null) {
-           xpathObj.fixupVariables(fVars, fGlobalsSize);
+        if (m_vars != null) {
+           xpathObj.fixupVariables(m_vars, m_globals_size);
         }
 
         Expression xpathExpr = xpathObj.getExpression();
@@ -210,8 +217,8 @@ public class XPathMapConstructor extends Expression {
                 
                 XPath xpathIndexObj = new XPath(xpathIndexExprStr, srcLocator, xctxt.getNamespaceContext(), 
                                                                                                   XPath.SELECT, null);
-                if (fVars != null) {
-                   xpathIndexObj.fixupVariables(fVars, fGlobalsSize);
+                if (m_vars != null) {
+                   xpathIndexObj.fixupVariables(m_vars, m_globals_size);
                 }
                 
                 XObject arrIndexEvalResult = xpathIndexObj.execute(xctxt, xctxt.getCurrentNode(), 
@@ -260,8 +267,8 @@ public class XPathMapConstructor extends Expression {
     	}
         else {
         	xpathObj = new XPath(xpathExprStr, srcLocator, xctxt.getNamespaceContext(), XPath.SELECT, null);
-            if (fVars != null) {
-               xpathObj.fixupVariables(fVars, fGlobalsSize);
+            if (m_vars != null) {
+               xpathObj.fixupVariables(m_vars, m_globals_size);
             }
             
             XObject xPathExprPartResult = xpathObj.execute(xctxt, contextNode, 
diff --git a/src/org/apache/xpath/composite/XPathSequenceConstructor.java b/src/org/apache/xpath/composite/XPathSequenceConstructor.java
index 65fd4b3ec..5e0d501c9 100644
--- a/src/org/apache/xpath/composite/XPathSequenceConstructor.java
+++ b/src/org/apache/xpath/composite/XPathSequenceConstructor.java
@@ -42,7 +42,7 @@ import org.apache.xpath.objects.XObject;
 
 import xml.xpath31.processor.types.XSNumericType;
 
-/*
+/**
  * This class implements and evaluates XPath 3.1 literal 
  * sequence constructor expressions.
  * 
@@ -56,10 +56,16 @@ public class XPathSequenceConstructor extends Expression {
     
     private List<String> sequenceConstructorXPathParts = new ArrayList<String>();
     
-    // The following two fields of this class, are used during 
-    // XPath.fixupVariables(..) action as performed within object of 
-    // this class.    
-    private Vector m_vars;    
+    /**
+     * This class field is used during, XPath.fixupVariables(..) action 
+     * as performed within object of this class.  
+     */    
+    private Vector m_vars;
+    
+    /**
+     * This class field is used during, XPath.fixupVariables(..) action 
+     * as performed within object of this class.  
+     */
     private int m_globals_size;
     
     @Override
diff --git a/src/org/apache/xpath/functions/FuncBoolean.java b/src/org/apache/xpath/functions/FuncBoolean.java
index 2cb41f47e..843596aee 100644
--- a/src/org/apache/xpath/functions/FuncBoolean.java
+++ b/src/org/apache/xpath/functions/FuncBoolean.java
@@ -15,9 +15,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-/*
- * $Id$
- */
 package org.apache.xpath.functions;
 
 import java.math.BigDecimal;
@@ -36,14 +33,15 @@ import org.apache.xpath.objects.XString;
 
 import xml.xpath31.processor.types.XSAnyURI;
 import xml.xpath31.processor.types.XSBoolean;
+import xml.xpath31.processor.types.XSDecimal;
+import xml.xpath31.processor.types.XSDouble;
+import xml.xpath31.processor.types.XSInteger;
 import xml.xpath31.processor.types.XSNumericType;
 import xml.xpath31.processor.types.XSString;
 import xml.xpath31.processor.types.XSUntypedAtomic;
 
 /**
  * Implementation of XPath 3.1 fn:boolean function.
- * 
- * @xsl.usage advanced
  */
 public class FuncBoolean extends FunctionOneArg
 {
@@ -74,76 +72,90 @@ public class FuncBoolean extends FunctionOneArg
    */
   public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
   {
-	XObject result = null;
-	
-	SourceLocator srcLocator = xctxt.getSAXLocator();
-	
-	XObject xObj = m_arg0.execute(xctxt);
-	
-	if (xObj instanceof ResultSequence) {
-	   ResultSequence rSeq = (ResultSequence)xObj;
-	   if (rSeq.size() == 0) {
-		  result = new XSBoolean(false); 
-	   }
-	   else {
-		  throw new javax.xml.transform.TransformerException("FORG0006 : Invalid argument type, for the "
-                                                                               + "function call fn:boolean.", srcLocator); 
-	   }
-	}
-	else if (xObj instanceof XNodeSet) {
-	   if (((XNodeSet)xObj).getLength() == 0) {
-	      result = new XSBoolean(false);
-	   }
-	   else {
-		  result = new XSBoolean(true); 
-	   }
-	}
-	else if (xObj instanceof XSBoolean) {
-	   result = xObj;
-	}
-	else if (xObj instanceof XBoolean) {
-	   XBoolean xBool = (XBoolean)xObj;
-	   result = new XSBoolean(xBool.bool());
-	}
-	else if ((xObj instanceof XSString) || (xObj instanceof XString) || 
-			 (xObj instanceof XSAnyURI) || (xObj instanceof XSUntypedAtomic)) {
-	   String argStrVal = XslTransformEvaluationHelper.getStrVal(xObj);
-	   if ((argStrVal == null) || (argStrVal.length() == 0)) {
-		  result = new XSBoolean(false); 
-	   }
-	   else {
-		  result = new XSBoolean(true);
-	   }
-	}
-	else if (xObj instanceof XSNumericType) {
-	   XSNumericType xsNumericType = (XSNumericType)xObj;
-	   String argStrVal = xsNumericType.stringValue();
-	   BigDecimal argBigDecimal = new BigDecimal(argStrVal);	   
-	   if ("NaN".equals(argStrVal)) {
-		  result = new XSBoolean(false);  
-	   }
-	   else if (argBigDecimal.compareTo(BigDecimal.valueOf(0)) == 0) {
-		  result = new XSBoolean(false); 
-	   }
-	   else {
-		  result = new XSBoolean(true); 
-	   }
-	}
-    else if (xObj instanceof XNumber) {
-	   double argDbl = ((XNumber)xObj).num();
-	   if (argDbl == 0d) {
-		  result = new XSBoolean(false);  
-	   }
-	   else {
-		  result = new XSBoolean(true);
-	   }
-	}
-    else {
-       throw new javax.xml.transform.TransformerException("FORG0006 : Invalid argument type, for the "
-       		                                                                + "function call fn:boolean.", srcLocator); 
-    } 
-	
-	return result;
+	  XObject result = null;
+
+	  SourceLocator srcLocator = xctxt.getSAXLocator();
+
+	  XObject xObj = m_arg0.execute(xctxt);
+
+	  if (xObj instanceof ResultSequence) {
+		  ResultSequence rSeq = (ResultSequence)xObj;
+		  if (rSeq.size() == 0) {
+			  result = new XSBoolean(false); 
+		  }
+		  else if (rSeq.item(0) instanceof XNodeSet) {
+			  result = new XSBoolean(true); 
+		  }
+		  else {
+			  throw new javax.xml.transform.TransformerException("FORG0006 : Invalid argument provided "
+					                                                            + "to function fn:boolean.", srcLocator);  
+		  }
+	  }
+	  else if (xObj instanceof XNodeSet) {
+		  if (((XNodeSet)xObj).getLength() == 0) {
+			  result = new XSBoolean(false);
+		  }
+		  else {
+			  result = new XSBoolean(true); 
+		  }
+	  }
+	  else if (xObj instanceof XSBoolean) {
+		  result = xObj;
+	  }
+	  else if (xObj instanceof XBoolean) {
+		  XBoolean xBool = (XBoolean)xObj;
+		  result = new XSBoolean(xBool.bool());
+	  }
+	  else if ((xObj instanceof XSString) || (xObj instanceof XString) || 
+			  (xObj instanceof XSAnyURI) || (xObj instanceof XSUntypedAtomic)) {
+		  String argStrVal = XslTransformEvaluationHelper.getStrVal(xObj);
+		  if ((argStrVal == null) || (argStrVal.length() == 0)) {
+			  result = new XSBoolean(false); 
+		  }
+		  else {
+			  result = new XSBoolean(true);
+		  }
+	  }
+	  else if (xObj instanceof XSNumericType) {
+		  XSNumericType xsNumericType = (XSNumericType)xObj;
+		  String argStrVal = xsNumericType.stringValue();
+		  BigDecimal argBigDecimal = new BigDecimal(argStrVal);	   
+		  if ("NaN".equals(argStrVal) || (argBigDecimal.compareTo(BigDecimal.valueOf(0)) == 0)) {
+			  result = new XSBoolean(false);  
+		  }
+		  else {
+			  result = new XSBoolean(true); 
+		  }
+	  }
+	  else if (xObj instanceof XNumber) {	  
+		  if (((XNumber)xObj).isXsInteger()) {
+			  XSInteger xsInteger = ((XNumber)xObj).getXsInteger();
+			  if ((xsInteger.getValue()).compareTo(BigDecimal.valueOf(0)) == 0) {
+				  result = new XSBoolean(false); 
+			  }
+		  }
+		  else if (((XNumber)xObj).isXsDecimal()) {
+			  XSDecimal xsDecimal = ((XNumber)xObj).getXsDecimal();
+			  if ((xsDecimal.getValue()).compareTo(BigDecimal.valueOf(0)) == 0) {
+				  result = new XSBoolean(false); 
+			  }
+		  }
+		  else if (((XNumber)xObj).isXsDouble()) {
+			  XSDouble xsDouble = ((XNumber)xObj).getXsDouble();
+			  if (xsDouble.nan() || (xsDouble.doubleValue() == 0d)) {
+				  result = new XSBoolean(false); 
+			  }
+		  }
+		  else {
+			  result = new XSBoolean(true);
+		  }
+	  }
+	  else {
+		  throw new javax.xml.transform.TransformerException("FORG0006 : Invalid argument provided "
+				                                                            + "to function fn:boolean.", srcLocator); 
+	  } 
+
+	  return result;
   }
   
 }
diff --git a/src/org/apache/xpath/functions/FuncFilter.java b/src/org/apache/xpath/functions/FuncFilter.java
index ce13fbc09..089606dad 100644
--- a/src/org/apache/xpath/functions/FuncFilter.java
+++ b/src/org/apache/xpath/functions/FuncFilter.java
@@ -74,11 +74,17 @@ public class FuncFilter extends Function2Args {
    
    private static final String FUNCTION_NAME = "filter()";
    
-   // The following two fields of this class, are used during 
-   // XPath.fixupVariables(..) action as performed within object of 
-   // this class.    
-   private Vector fVars;    
-   private int fGlobalsSize;
+   /**
+    * This class field is used during, XPath.fixupVariables(..) action 
+    * as performed within object of this class.  
+    */    
+   private Vector m_vars;
+   
+   /**
+    * This class field is used during, XPath.fixupVariables(..) action 
+    * as performed within object of this class.  
+    */
+   private int m_globals_size;
 
    /**
    * Execute the function. The function must return a valid object.
@@ -168,8 +174,8 @@ public class FuncFilter extends Function2Args {
   
   public void fixupVariables(java.util.Vector vars, int globalsSize)
   {
-      fVars = (Vector)(vars.clone());
-      fGlobalsSize = globalsSize; 
+      m_vars = (Vector)(vars.clone());
+      m_globals_size = globalsSize; 
   }
   
   /*
@@ -257,11 +263,11 @@ public class FuncFilter extends Function2Args {
                   inlineFunctionVarMap.put(varQname, inpSeqItem);
                }
                
-               if (fVars != null) {
+               if (m_vars != null) {
                   if (!m_xpathVarList.contains(varQname)) {
                      m_xpathVarList.add(varQname);
                   }
-                  inlineFnXpath.fixupVariables(fVars, fGlobalsSize);
+                  inlineFnXpath.fixupVariables(m_vars, m_globals_size);
                   m_xpathVarList.remove(varQname);
                }
                
diff --git a/src/org/apache/xpath/functions/FuncForEach.java b/src/org/apache/xpath/functions/FuncForEach.java
index 3e4acb80b..a3b68d386 100644
--- a/src/org/apache/xpath/functions/FuncForEach.java
+++ b/src/org/apache/xpath/functions/FuncForEach.java
@@ -53,11 +53,17 @@ public class FuncForEach extends Function2Args {
 
    private static final long serialVersionUID = 2912594883291006421L;
    
-   // The following two fields of this class, are used during 
-   // XPath.fixupVariables(..) action as performed within object of 
-   // this class.    
-   private Vector fVars;    
-   private int fGlobalsSize;
+   /**
+    * This class field is used during, XPath.fixupVariables(..) action 
+    * as performed within object of this class.  
+    */    
+   private Vector m_vars;
+   
+   /**
+    * This class field is used during, XPath.fixupVariables(..) action 
+    * as performed within object of this class.  
+    */
+   private int m_globals_size;
 
    /**
    * Implementation of the function. The function must return a valid object.
@@ -83,8 +89,8 @@ public class FuncForEach extends Function2Args {
         DTMIterator arg0DtmIterator = null;        
         XObject arg0XsObject = null;
         
-        if (fVars != null) {
-           arg0.fixupVariables(fVars, fGlobalsSize);
+        if (m_vars != null) {
+           arg0.fixupVariables(m_vars, m_globals_size);
         }
                   
         if (arg0 instanceof LocPathIterator) {
@@ -107,8 +113,8 @@ public class FuncForEach extends Function2Args {
             		                                   resultSeq, namedFuncRef);
         }
         else if (arg1 instanceof Variable) {
-            if (fVars != null) {
-               arg1.fixupVariables(fVars, fGlobalsSize);
+            if (m_vars != null) {
+               arg1.fixupVariables(m_vars, m_globals_size);
             }            
             XObject arg1VarValue = arg1.execute(xctxt);
             if (arg1VarValue instanceof XPathInlineFunction) {
@@ -163,8 +169,8 @@ public class FuncForEach extends Function2Args {
   
   public void fixupVariables(java.util.Vector vars, int globalsSize)
   {
-      fVars = (Vector)(vars.clone());
-      fGlobalsSize = globalsSize; 
+      m_vars = (Vector)(vars.clone());
+      m_globals_size = globalsSize; 
   }
   
   /*
@@ -231,11 +237,11 @@ public class FuncForEach extends Function2Args {
                   inlineFunctionVarMap.put(varQname, inpSeqItem);
                }
                
-               if (fVars != null) {                  
+               if (m_vars != null) {                  
                   if (!m_xpathVarList.contains(varQname)) {
                      m_xpathVarList.add(varQname);
                   }
-                  inlineFnXpath.fixupVariables(fVars, fGlobalsSize);
+                  inlineFnXpath.fixupVariables(m_vars, m_globals_size);
                   m_xpathVarList.remove(varQname);
                }
                
diff --git a/src/org/apache/xpath/functions/FuncNot.java b/src/org/apache/xpath/functions/FuncNot.java
index 22c129097..58fb47e1c 100644
--- a/src/org/apache/xpath/functions/FuncNot.java
+++ b/src/org/apache/xpath/functions/FuncNot.java
@@ -29,12 +29,10 @@ import xml.xpath31.processor.types.XSBoolean;
 
 /**
  * Implementation of XPath 3.1 fn:not function.
- * 
- * @xsl.usage advanced
  */
 public class FuncNot extends FunctionOneArg
 {
-    static final long serialVersionUID = 7299699961076329790L;
+   static final long serialVersionUID = 7299699961076329790L;
 
   /**
    * Implementation of the function. The function must return
@@ -47,27 +45,32 @@ public class FuncNot extends FunctionOneArg
    */
   public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
   {	  
-	 XObject result = null;
-	 
-	 SourceLocator srcLocator = xctxt.getSAXLocator(); 
-	 
-	 try {
-		FuncBoolean fnBoolean = new FuncBoolean(m_arg0);
-	    result = fnBoolean.execute(xctxt);
-	 }
-	 catch (javax.xml.transform.TransformerException ex) {
-		throw new javax.xml.transform.TransformerException("FORG0006 : Invalid argument type, for the "
-                                                                             + "function call fn:not.", srcLocator); 
-	 }
+	  XObject result = null;
 
-	 if (((XSBoolean)result).value()) {
-		 result = new XSBoolean(false);  
-	 }
-	 else {
-		 result = new XSBoolean(true);
-	 }
-	 
-	 return result;
+	  SourceLocator srcLocator = xctxt.getSAXLocator(); 
+
+	  try {
+		  FuncBoolean fnBoolean = new FuncBoolean(m_arg0);
+		  result = fnBoolean.execute(xctxt);
+	  }
+	  catch (javax.xml.transform.TransformerException ex) {
+		  throw new javax.xml.transform.TransformerException("FORG0006 : Invalid argument provided "
+				                                                            + "to function fn:not.", srcLocator); 
+	  }
+ 
+	  /**
+	   * Result of fn:not function is boolean negation of fn:boolean 
+	   * function's result. 
+	   */
+	  
+	  if (((XSBoolean)result).value()) {
+		  result = new XSBoolean(false);  
+	  }
+	  else {
+		  result = new XSBoolean(true);
+	  }
+
+	  return result;
 	 
   }
   
diff --git a/src/org/apache/xpath/functions/FunctionOneArg.java b/src/org/apache/xpath/functions/FunctionOneArg.java
index 124e9d876..04b005f39 100644
--- a/src/org/apache/xpath/functions/FunctionOneArg.java
+++ b/src/org/apache/xpath/functions/FunctionOneArg.java
@@ -33,7 +33,7 @@ public class FunctionOneArg extends Function implements ExpressionOwner
 {
   static final long serialVersionUID = -5180174180765609758L;
   
-  private boolean fArgCountErr = false;
+  private boolean m_arg_count_err = false;
 
   /**
    * Return the first argument passed to the function (at index 0).
@@ -65,7 +65,7 @@ public class FunctionOneArg extends Function implements ExpressionOwner
       arg.exprSetParent(this);
     }
     else {
-      fArgCountErr = true;
+      m_arg_count_err = true;
       reportWrongNumberArgs();
     }
   }
@@ -95,7 +95,7 @@ public class FunctionOneArg extends Function implements ExpressionOwner
   }
   
   protected boolean isArgCountErr() {
-      return fArgCountErr;
+      return m_arg_count_err;
   }
   
   /**
diff --git a/src/org/apache/xpath/functions/array/FuncArrayFilter.java b/src/org/apache/xpath/functions/array/FuncArrayFilter.java
index 21d4fbebe..0aed81e14 100644
--- a/src/org/apache/xpath/functions/array/FuncArrayFilter.java
+++ b/src/org/apache/xpath/functions/array/FuncArrayFilter.java
@@ -54,11 +54,17 @@ public class FuncArrayFilter extends Function2Args {
    
    private static final long serialVersionUID = -7341393974878279742L;
    
-   // The following two fields of this class, are used during 
-   // XPath.fixupVariables(..) action as performed within object of 
-   // this class.    
-   private Vector fVars;    
-   private int fGlobalsSize;
+   /**
+    * This class field is used during, XPath.fixupVariables(..) action 
+    * as performed within object of this class.  
+    */    
+   private Vector m_vars;
+   
+   /**
+    * This class field is used during, XPath.fixupVariables(..) action 
+    * as performed within object of this class.  
+    */
+   private int m_globals_size;
 
    /**
    * Implementation of the function. The function must return a valid object.
@@ -81,8 +87,8 @@ public class FuncArrayFilter extends Function2Args {
         Expression arg0 = getArg0();
         Expression arg1 = getArg1();
         
-        if (fVars != null) {
-           arg0.fixupVariables(fVars, fGlobalsSize);
+        if (m_vars != null) {
+           arg0.fixupVariables(m_vars, m_globals_size);
         }
         
         XObject arg0XsObject = arg0.execute(xctxt, contextNode);
@@ -133,8 +139,8 @@ public class FuncArrayFilter extends Function2Args {
   
   public void fixupVariables(java.util.Vector vars, int globalsSize)
   {
-      fVars = (Vector)(vars.clone());
-      fGlobalsSize = globalsSize; 
+      m_vars = (Vector)(vars.clone());
+      m_globals_size = globalsSize; 
   }
   
   /**
diff --git a/src/org/apache/xpath/functions/array/FuncArrayForEach.java b/src/org/apache/xpath/functions/array/FuncArrayForEach.java
index c97dfd1cb..b75d7a415 100644
--- a/src/org/apache/xpath/functions/array/FuncArrayForEach.java
+++ b/src/org/apache/xpath/functions/array/FuncArrayForEach.java
@@ -53,11 +53,17 @@ public class FuncArrayForEach extends Function2Args {
 
    private static final long serialVersionUID = 2912594883291006421L;
    
-   // The following two fields of this class, are used during 
-   // XPath.fixupVariables(..) action as performed within object of 
-   // this class.    
-   private Vector fVars;    
-   private int fGlobalsSize;
+   /**
+    * This class field is used during, XPath.fixupVariables(..) action 
+    * as performed within object of this class.  
+    */    
+   private Vector m_vars;
+   
+   /**
+    * This class field is used during, XPath.fixupVariables(..) action 
+    * as performed within object of this class.  
+    */
+   private int m_globals_size;
 
    /**
    * Implementation of the function. The function must return a valid object.
@@ -80,8 +86,8 @@ public class FuncArrayForEach extends Function2Args {
         Expression arg0 = getArg0();
         Expression arg1 = getArg1();                
         
-        if (fVars != null) {
-           arg0.fixupVariables(fVars, fGlobalsSize);
+        if (m_vars != null) {
+           arg0.fixupVariables(m_vars, m_globals_size);
         }
         
         XObject arg0XsObject = arg0.execute(xctxt, contextNode);
@@ -97,8 +103,8 @@ public class FuncArrayForEach extends Function2Args {
             result = evaluateArrayForEach(xctxt, (XPathArray)arg0XsObject, inlineFuncArg); 
         }
         else if (arg1 instanceof Variable) {
-            if (fVars != null) {
-               arg1.fixupVariables(fVars, fGlobalsSize);
+            if (m_vars != null) {
+               arg1.fixupVariables(m_vars, m_globals_size);
             }
             
             XObject arg1VarValue = arg1.execute(xctxt);
@@ -136,8 +142,8 @@ public class FuncArrayForEach extends Function2Args {
   
   public void fixupVariables(java.util.Vector vars, int globalsSize)
   {
-      fVars = (Vector)(vars.clone());
-      fGlobalsSize = globalsSize; 
+      m_vars = (Vector)(vars.clone());
+      m_globals_size = globalsSize; 
   }
   
   /**
diff --git a/src/org/apache/xpath/functions/map/FuncMapForEach.java b/src/org/apache/xpath/functions/map/FuncMapForEach.java
index e9e6e1839..7cfaa1c85 100644
--- a/src/org/apache/xpath/functions/map/FuncMapForEach.java
+++ b/src/org/apache/xpath/functions/map/FuncMapForEach.java
@@ -53,11 +53,17 @@ public class FuncMapForEach extends Function2Args {
 
 	private static final long serialVersionUID = 4474670594915534994L;
 	
-	// The following two fields of this class, are used during 
-	// XPath.fixupVariables(..) action as performed within object of 
-	// this class.    
-	private Vector fVars;    
-	private int fGlobalsSize;
+	/**
+	 * This class field is used during, XPath.fixupVariables(..) action 
+	 * as performed within object of this class.  
+	 */    
+	private Vector m_vars;
+	  
+	/**
+	 * This class field is used during, XPath.fixupVariables(..) action 
+	 * as performed within object of this class.  
+	 */
+	private int m_globals_size;
 
 	/**
 	 * Implementation of the function. The function must return a valid object.
@@ -79,8 +85,8 @@ public class FuncMapForEach extends Function2Args {
 
 		XObject arg0XsObject = null;
 
-		if (fVars != null) {
-		   arg0.fixupVariables(fVars, fGlobalsSize);
+		if (m_vars != null) {
+		   arg0.fixupVariables(m_vars, m_globals_size);
 		}
 
 		if (arg0 instanceof XPathMap) {
@@ -107,8 +113,8 @@ public class FuncMapForEach extends Function2Args {
 			result = evaluateFnMapforEach(xctxt, (XPathMap)arg0XsObject, inlineFuncArg); 
 		}
 		else if (arg1 instanceof Variable) {
-			if (fVars != null) {
-				arg1.fixupVariables(fVars, fGlobalsSize);
+			if (m_vars != null) {
+				arg1.fixupVariables(m_vars, m_globals_size);
 			}
 
 			XObject arg1VarValue = arg1.execute(xctxt);
@@ -157,8 +163,8 @@ public class FuncMapForEach extends Function2Args {
 
 	public void fixupVariables(java.util.Vector vars, int globalsSize)
 	{
-		fVars = (Vector)(vars.clone());
-		fGlobalsSize = globalsSize; 
+		m_vars = (Vector)(vars.clone());
+		m_globals_size = globalsSize; 
 	}
 
 	/*
diff --git a/tests/func_boolean_values/gold/test1.out b/tests/func_boolean_values/gold/test1.out
new file mode 100644
index 000000000..24b3f7faf
--- /dev/null
+++ b/tests/func_boolean_values/gold/test1.out
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?><result>
+  <one>true</one>
+  <two>false</two>
+  <three>false</three>
+  <four>true</four>
+  <five>false</five>
+</result>
diff --git a/tests/func_boolean_values/test1.xsl b/tests/func_boolean_values/test1.xsl
new file mode 100644
index 000000000..7c08ef6a3
--- /dev/null
+++ b/tests/func_boolean_values/test1.xsl
@@ -0,0 +1,50 @@
+<?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 -->
+   
+   <!-- XSLT test case to test, XPath 3.1 functions fn:boolean and fn:not -->                			
+
+   <xsl:output method="xml" indent="yes"/>
+
+   <xsl:template match="/">
+	  <result>
+	     <xsl:variable name="abc" select="('a', 'b', '')"/>
+		 <one>
+		   <xsl:value-of select="let $item := $abc[1] return boolean($item)"/>
+		 </one>
+		 <two>
+		   <xsl:value-of select="let $item := $abc[3] return boolean($item)"/>
+		 </two>
+		 <three>
+		   <xsl:value-of select="not(true())"/>
+		 </three>
+		 <four>
+		   <xsl:value-of select="not(())"/>
+		 </four>
+		 <five>
+		   <xsl:value-of select="not('false')"/>
+		 </five>
+	  </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/org/apache/xalan/xpath3/FuncBooleanValuesTests.java b/tests/org/apache/xalan/xpath3/FuncBooleanValuesTests.java
new file mode 100644
index 000000000..20d223aac
--- /dev/null
+++ b/tests/org/apache/xalan/xpath3/FuncBooleanValuesTests.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.xalan.xpath3;
+
+import org.apache.xalan.util.XSLConstants;
+import org.apache.xalan.util.XSLTransformTestsUtil;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * XPath 3.1 test cases for functions fn:boolean and fn:not.
+ * 
+ * @author Mukul Gandhi <mu...@apache.org>
+ * 
+ * @xsl.usage advanced
+ */
+public class FuncBooleanValuesTests extends XSLTransformTestsUtil {        
+    
+    private static final String XSL_TRANSFORM_INPUT_DIRPATH = XSLConstants.XSL_TRANSFORM_INPUT_DIRPATH_PREFIX 
+    																								+ "func_boolean_values/";
+    
+    private static final String XSL_TRANSFORM_GOLD_DIRPATH = XSLConstants.XSL_TRANSFORM_GOLD_DIRPATH_PREFIX 
+    																								+ "func_boolean_values/gold/";
+
+    @BeforeClass
+    public static void setUpBeforeClass() throws Exception {
+        // no op
+    }
+
+    @AfterClass
+    public static void tearDownAfterClass() throws Exception {        
+        xmlDocumentBuilderFactory = null;
+        xmlDocumentBuilder = null;
+        xslTransformerFactory = null;
+    }
+
+    @Test
+    public void xslFuncBooleanValuesTest1() {
+        String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test1.xsl"; 
+        String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test1.xsl";
+        
+        String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test1.out";                
+        
+        runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+    }
+
+}
diff --git a/tests/org/apache/xalan/xslt3/Xsl3TestSuite1.java b/tests/org/apache/xalan/xslt3/Xsl3TestSuite1.java
index 3383168c6..33e67bbee 100644
--- a/tests/org/apache/xalan/xslt3/Xsl3TestSuite1.java
+++ b/tests/org/apache/xalan/xslt3/Xsl3TestSuite1.java
@@ -38,6 +38,7 @@ import org.apache.xalan.xpath3.FnQNameTests;
 import org.apache.xalan.xpath3.FnResolveQNameTests;
 import org.apache.xalan.xpath3.FnRootTests;
 import org.apache.xalan.xpath3.FnXmlToJsonTests;
+import org.apache.xalan.xpath3.FuncBooleanValuesTests;
 import org.apache.xalan.xpath3.InlineFunctionItemExprTests;
 import org.apache.xalan.xpath3.JiraIssuesTests;
 import org.apache.xalan.xpath3.StringTests;
@@ -82,7 +83,7 @@ import org.junit.runners.Suite.SuiteClasses;
                 FnXmlToJsonTests.class, FnAnalyzeStringTests.class, XPathMapOtherTests.class,
                 JiraIssuesTests.class, XPathNamedFunctionReferenceTests.class, FnApplyTests.class,
                 XPathGeneralComparisonOpTests.class, FnMapFindTests.class, XPathNumericArithmeticTests.class,
-                XslTunnelParameterTests.class })
+                XslTunnelParameterTests.class, FuncBooleanValuesTests.class })
 public class Xsl3TestSuite1 {
 
 }


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