You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by mu...@apache.org on 2023/07/26 13:39:40 UTC

[xalan-java] branch xalan-j_xslt3.0 updated: committing improvements to XML namespace handling, within recently implemented xalanj xslt 3.0 codebase. also committing, few new related xalanj 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 16900b77 committing improvements to XML namespace handling, within recently implemented xalanj xslt 3.0 codebase. also committing, few new related xalanj test cases as well.
     new faa8b9a3 Merge pull request #36 from mukulga/xalan-j_xslt3.0_mukul
16900b77 is described below

commit 16900b77d48d0f79121bea9270e25e88dc851ce2
Author: Mukul Gandhi <ga...@gmail.com>
AuthorDate: Wed Jul 26 19:04:02 2023 +0530

    committing improvements to XML namespace handling, within recently implemented xalanj xslt 3.0 codebase. also committing, few new related xalanj test cases as well.
---
 src/org/apache/xalan/templates/AVTPartXPath.java   |  5 ++
 src/org/apache/xalan/templates/ElemForEach.java    | 14 +++++-
 .../apache/xalan/templates/ElemLiteralResult.java  | 21 +++++++--
 .../xalan/templates/ElemTemplateElement.java       |  2 +-
 src/org/apache/xalan/templates/ElemValueOf.java    | 16 +++++++
 .../xalan/templates/XSConstructorFunctionUtil.java | 42 +++++++++++++----
 ...lper.java => XslTransformEvaluationHelper.java} | 29 ++++++++++--
 src/org/apache/xpath/composite/ForExpr.java        | 39 ++++++++++++---
 src/org/apache/xpath/composite/IfExpr.java         | 41 +++++++++++++---
 src/org/apache/xpath/composite/LetExpr.java        | 31 +++++++++---
 src/org/apache/xpath/composite/QuantifiedExpr.java | 38 +++++++++++++--
 .../xpath/composite/SimpleSequenceConstructor.java | 20 ++++++--
 .../xpath/functions/DynamicFunctionCall.java       | 30 ++++++++++--
 .../apache/xpath/functions/FuncExtFunction.java    | 28 ++++++++++-
 src/org/apache/xpath/operations/Mult.java          | 10 ++++
 src/org/apache/xpath/operations/Operation.java     | 51 ++++++++++++++++++--
 src/org/apache/xpath/operations/Range.java         | 55 +++++++++++++++++++---
 tests/for_expr/gold/test10.out                     |  1 +
 tests/for_expr/gold/test8.out                      |  1 +
 tests/for_expr/gold/test9.out                      |  1 +
 tests/{let_expr/test3.xsl => for_expr/test10.xsl}  | 27 +++++------
 tests/{let_expr/test3.xsl => for_expr/test8.xsl}   | 25 +++++-----
 tests/{let_expr/test3.xsl => for_expr/test9.xsl}   | 26 +++++-----
 tests/if_expr/gold/test10.out                      |  5 ++
 tests/if_expr/gold/test11.out                      | 10 ++++
 tests/if_expr/gold/test9.out                       |  7 +++
 tests/if_expr/test10.xsl                           | 51 ++++++++++++++++++++
 tests/if_expr/test1_g.xml                          | 12 +++++
 tests/{let_expr/test3.xsl => if_expr/test8.xsl}    | 34 ++++++++-----
 tests/if_expr/test9.xsl                            | 52 ++++++++++++++++++++
 tests/let_expr/gold/test4.out                      |  1 +
 tests/let_expr/gold/test5.out                      |  1 +
 tests/let_expr/gold/test6.out                      | 12 +++++
 tests/let_expr/gold/test7.out                      |  5 ++
 tests/let_expr/gold/test8.out                      |  7 +++
 tests/let_expr/test1_b.xml                         |  6 +++
 tests/let_expr/test3.xsl                           |  6 +--
 tests/let_expr/{test3.xsl => test4.xsl}            | 25 +++++-----
 tests/let_expr/{test3.xsl => test5.xsl}            | 26 +++++-----
 tests/let_expr/{test3.xsl => test6.xsl}            | 31 +++++++-----
 tests/let_expr/{test3.xsl => test7.xsl}            | 29 ++++++------
 tests/let_expr/{test3.xsl => test8.xsl}            | 30 ++++++------
 .../apache/xalan/util/XslTransformTestsUtil.java   |  1 +
 tests/org/apache/xalan/xpath3/ForExprTests.java    | 30 ++++++++++++
 tests/org/apache/xalan/xpath3/IfExprTests.java     | 30 ++++++++++++
 tests/org/apache/xalan/xpath3/LetExprTests.java    | 50 ++++++++++++++++++++
 .../apache/xalan/xpath3/QuantifiedExprTests.java   | 10 ++++
 tests/quantified_expr/gold/test11.out              |  4 ++
 .../test3.xsl => quantified_expr/test10.xsl}       | 29 +++++++-----
 tests/quantified_expr/test1_g.xml                  | 12 +++++
 50 files changed, 868 insertions(+), 201 deletions(-)

diff --git a/src/org/apache/xalan/templates/AVTPartXPath.java b/src/org/apache/xalan/templates/AVTPartXPath.java
index 595d5173..c1f19d77 100644
--- a/src/org/apache/xalan/templates/AVTPartXPath.java
+++ b/src/org/apache/xalan/templates/AVTPartXPath.java
@@ -152,4 +152,9 @@ public class AVTPartXPath extends AVTPart
   {
   	m_xpath.getExpression().callVisitors(m_xpath, visitor);
   }
+
+  public XPath getXPath() {
+    return m_xpath;
+  }
+
 }
diff --git a/src/org/apache/xalan/templates/ElemForEach.java b/src/org/apache/xalan/templates/ElemForEach.java
index ca67254d..6acbc0ad 100644
--- a/src/org/apache/xalan/templates/ElemForEach.java
+++ b/src/org/apache/xalan/templates/ElemForEach.java
@@ -38,6 +38,7 @@ import org.apache.xpath.ExpressionOwner;
 import org.apache.xpath.XPath;
 import org.apache.xpath.XPathContext;
 import org.apache.xpath.composite.ForExpr;
+import org.apache.xpath.composite.SimpleSequenceConstructor;
 import org.apache.xpath.functions.Function;
 import org.apache.xpath.objects.ResultSequence;
 import org.apache.xpath.objects.XObject;
@@ -344,7 +345,7 @@ public class ElemForEach extends ElemTemplateElement implements ExpressionOwner
         XObject evalResult = ((Function)m_selectExpression).execute(xctxt);
         if (evalResult instanceof ResultSequence) {
             processResultSequence(transformer, xctxt, evalResult);
-            transformer.setXPathContext(xctxtOriginal);
+            transformer.setXPathContext(xctxtOriginal);            
             return;
         }                
     }
@@ -357,7 +358,7 @@ public class ElemForEach extends ElemTemplateElement implements ExpressionOwner
         XObject evalResult = ((Variable)m_selectExpression).execute(xctxt);
         if (evalResult instanceof ResultSequence) {
             processResultSequence(transformer, xctxt, evalResult);
-            transformer.setXPathContext(xctxtOriginal);
+            transformer.setXPathContext(xctxtOriginal);            
             return;
         }
     }
@@ -379,6 +380,15 @@ public class ElemForEach extends ElemTemplateElement implements ExpressionOwner
         return;
     }
     
+    if (m_selectExpression instanceof SimpleSequenceConstructor) {
+        SimpleSequenceConstructor seqCtrExpr = (SimpleSequenceConstructor)
+                                                                     m_selectExpression;
+        XObject  evalResult = seqCtrExpr.execute(xctxt);
+        processResultSequence(transformer, xctxt, evalResult);
+        transformer.setXPathContext(xctxtOriginal);
+        return;
+    }
+    
     // process the node-set, with body of xsl:for-each element as usual 
     final int sourceNode = xctxt.getCurrentNode();
     DTMIterator sourceNodes = m_selectExpression.asIterator(xctxt, sourceNode);
diff --git a/src/org/apache/xalan/templates/ElemLiteralResult.java b/src/org/apache/xalan/templates/ElemLiteralResult.java
index d0bb6c32..34912616 100644
--- a/src/org/apache/xalan/templates/ElemLiteralResult.java
+++ b/src/org/apache/xalan/templates/ElemLiteralResult.java
@@ -32,6 +32,8 @@ import org.apache.xalan.transformer.TransformerImpl;
 import org.apache.xml.serializer.SerializationHandler;
 import org.apache.xml.utils.StringVector;
 import org.apache.xpath.XPathContext;
+import org.apache.xpath.objects.XObject;
+import org.apache.xpath.xs.types.XSAnyType;
 import org.w3c.dom.Attr;
 import org.w3c.dom.DOMException;
 import org.w3c.dom.Document;
@@ -45,7 +47,7 @@ import org.xml.sax.SAXException;
 
 /**
  * Implement a Literal Result Element.
- * @see <a href="http://www.w3.org/TR/xslt#literal-result-element">literal-result-element in XSLT Specification</a>
+ * @see <a href="https://www.w3.org/TR/xslt-30/#literal-result-element">literal-result-element within XSLT 3.0 Specification</a>
  * @xsl.usage advanced
  */
 public class ElemLiteralResult extends ElemUse
@@ -1350,8 +1352,21 @@ public class ElemLiteralResult extends ElemUse
                     AVT avt = (AVT) m_avts.get(i);
                     XPathContext xctxt = transformer.getXPathContext();
                     int sourceNode = xctxt.getCurrentNode();
-                    String stringedValue = avt.evaluate(xctxt, sourceNode, this);
-
+                    XObject xpath3ContextItem = xctxt.getXPath3ContextItem();
+                    String avtStr = avt.getSimpleString();
+                    String stringedValue = null;
+                    if ("{.}".equals(avtStr) && xpath3ContextItem != null) {
+                        if (xpath3ContextItem instanceof XSAnyType) {
+                           stringedValue = ((XSAnyType)xpath3ContextItem).stringValue();    
+                        }
+                        else {
+                           stringedValue = xpath3ContextItem.str();  
+                        } 
+                    }
+                    else {
+                       stringedValue = avt.evaluate(xctxt, sourceNode, this);
+                    }
+                    
                     if (stringedValue != null)
                     {
 
diff --git a/src/org/apache/xalan/templates/ElemTemplateElement.java b/src/org/apache/xalan/templates/ElemTemplateElement.java
index fcb7f3b6..4d6d37d9 100644
--- a/src/org/apache/xalan/templates/ElemTemplateElement.java
+++ b/src/org/apache/xalan/templates/ElemTemplateElement.java
@@ -967,7 +967,7 @@ public class ElemTemplateElement extends UnImplNode
    *
    * @return reference to vector of {@link XMLNSDecl}s, which may be null.
    */
-  List getPrefixTable()
+  public List getPrefixTable()
   {
     return m_prefixTable;
   }
diff --git a/src/org/apache/xalan/templates/ElemValueOf.java b/src/org/apache/xalan/templates/ElemValueOf.java
index dc9706da..278b653d 100644
--- a/src/org/apache/xalan/templates/ElemValueOf.java
+++ b/src/org/apache/xalan/templates/ElemValueOf.java
@@ -28,6 +28,7 @@ import org.apache.xpath.Expression;
 import org.apache.xpath.XPath;
 import org.apache.xpath.XPathContext;
 import org.apache.xpath.axes.LocPathIterator;
+import org.apache.xpath.composite.LetExpr;
 import org.apache.xpath.functions.DynamicFunctionCall;
 import org.apache.xpath.functions.FuncExtFunction;
 import org.apache.xpath.functions.Function;
@@ -413,6 +414,21 @@ public class ElemValueOf extends ElemTemplateElement {
                         (new XString(nodeSetStrValue)).dispatchCharactersEvents(rth);
                      }
                   }
+                  else if (expr instanceof LetExpr) {
+                     LetExpr letExpr = (LetExpr)expr;
+                      
+                     XObject evalResult = letExpr.execute(xctxt);
+                     
+                     String strValue = null;                     
+                     if (evalResult instanceof XSAnyType) {
+                        strValue = ((XSAnyType)evalResult).stringValue();
+                     }
+                     else {
+                        strValue = evalResult.str();
+                     }
+                     
+                     (new XString(strValue)).dispatchCharactersEvents(rth);
+                  }
                   else {
                      expr.executeCharsToContentHandler(xctxt, rth);
                   }
diff --git a/src/org/apache/xalan/templates/XSConstructorFunctionUtil.java b/src/org/apache/xalan/templates/XSConstructorFunctionUtil.java
index f06455f8..2dfdbb40 100644
--- a/src/org/apache/xalan/templates/XSConstructorFunctionUtil.java
+++ b/src/org/apache/xalan/templates/XSConstructorFunctionUtil.java
@@ -26,6 +26,7 @@ import org.apache.xpath.functions.FuncExtFunction;
 import org.apache.xpath.objects.ResultSequence;
 import org.apache.xpath.objects.XObject;
 import org.apache.xpath.operations.Operation;
+import org.apache.xpath.xs.types.XSAnyType;
 import org.apache.xpath.xs.types.XSBoolean;
 import org.apache.xpath.xs.types.XSDate;
 import org.apache.xpath.xs.types.XSDecimal;
@@ -37,7 +38,7 @@ import org.apache.xpath.xs.types.XSLong;
 import org.xml.sax.SAXException;
 
 /**
- * An utility class, to support evaluations of XPath 3.1 constructor 
+ * An utility class, to support evaluation of XPath 3.1 constructor 
  * functions (ref, https://www.w3.org/TR/xpath-functions-31/#constructor-functions), 
  * and few other XPath expression evaluations.
  * 
@@ -49,7 +50,10 @@ public class XSConstructorFunctionUtil {
     
     /*
      * Process an XPath expression of the type FuncExtFunction, XPath operation, 
-     * and also few default XPath expression processing. 
+     * and also few default XPath expression processing.
+     * 
+     * We use the XalanJ extension function evaluation mechanism, to evaluate
+     * XPath 3.1 constructor functions.
      */
     public static XObject processFuncExtFunctionOrXPathOpn(XPathContext xctxt, Expression expr)
                                                                     throws TransformerException, SAXException {        
@@ -65,7 +69,7 @@ public class XSConstructorFunctionUtil {
                     ResultSequence argSequence = new ResultSequence();
                     for (int idx = 0; idx < funcExtFunction.getArgCount(); idx++) {
                         XObject argVal = (funcExtFunction.getArg(idx)).execute(xctxt);
-                        argSequence.add(new XSDecimal(argVal.str()));
+                        argSequence.add(new XSDecimal(getSimpleStrVal(argVal)));
                     }
 
                     ResultSequence rSeq = (new XSDecimal()).constructor(argSequence);
@@ -75,7 +79,7 @@ public class XSConstructorFunctionUtil {
                     ResultSequence argSequence = new ResultSequence();
                     for (int idx = 0; idx < funcExtFunction.getArgCount(); idx++) {
                         XObject argVal = (funcExtFunction.getArg(idx)).execute(xctxt);
-                        argSequence.add(new XSFloat(argVal.str()));
+                        argSequence.add(new XSFloat(getSimpleStrVal(argVal)));
                     }
 
                     ResultSequence rSeq = (new XSFloat()).constructor(argSequence);
@@ -85,7 +89,7 @@ public class XSConstructorFunctionUtil {
                     ResultSequence argSequence = new ResultSequence();
                     for (int idx = 0; idx < funcExtFunction.getArgCount(); idx++) {
                         XObject argVal = (funcExtFunction.getArg(idx)).execute(xctxt);
-                        argSequence.add(new XSDouble(argVal.str()));
+                        argSequence.add(new XSDouble(getSimpleStrVal(argVal)));
                     }
 
                     ResultSequence rSeq = (new XSDouble()).constructor(argSequence);
@@ -95,7 +99,7 @@ public class XSConstructorFunctionUtil {
                     ResultSequence argSequence = new ResultSequence();
                     for (int idx = 0; idx < funcExtFunction.getArgCount(); idx++) {
                         XObject argVal = (funcExtFunction.getArg(idx)).execute(xctxt);
-                        argSequence.add(new XSInteger(argVal.str()));
+                        argSequence.add(new XSInteger(getSimpleStrVal(argVal)));
                     }
 
                     ResultSequence rSeq = (new XSInteger()).constructor(argSequence);
@@ -105,7 +109,7 @@ public class XSConstructorFunctionUtil {
                     ResultSequence argSequence = new ResultSequence();
                     for (int idx = 0; idx < funcExtFunction.getArgCount(); idx++) {
                         XObject argVal = (funcExtFunction.getArg(idx)).execute(xctxt);
-                        argSequence.add(new XSLong(argVal.str()));
+                        argSequence.add(new XSLong(getSimpleStrVal(argVal)));
                     }
 
                     ResultSequence rSeq = (new XSLong()).constructor(argSequence);
@@ -115,7 +119,7 @@ public class XSConstructorFunctionUtil {
                     ResultSequence argSequence = new ResultSequence();
                     for (int idx = 0; idx < funcExtFunction.getArgCount(); idx++) {
                         XObject argVal = (funcExtFunction.getArg(idx)).execute(xctxt);
-                        argSequence.add(new XSInt(argVal.str()));
+                        argSequence.add(new XSInt(getSimpleStrVal(argVal)));
                     }
 
                     ResultSequence rSeq = (new XSInt()).constructor(argSequence);
@@ -125,7 +129,8 @@ public class XSConstructorFunctionUtil {
                     ResultSequence argSequence = new ResultSequence();
                     for (int idx = 0; idx < funcExtFunction.getArgCount(); idx++) {
                         XObject argVal = (funcExtFunction.getArg(idx)).execute(xctxt);
-                        Boolean boolVal = Boolean.valueOf("0".equals(argVal.str()) ? "false" : "true");
+                        Boolean boolVal = Boolean.valueOf("0".equals(getSimpleStrVal(argVal)) ? 
+                                                                                 "false" : "true");
                         argSequence.add(new XSBoolean(boolVal));
                     }
 
@@ -136,7 +141,7 @@ public class XSConstructorFunctionUtil {
                     ResultSequence argSequence = new ResultSequence();
                     for (int idx = 0; idx < funcExtFunction.getArgCount(); idx++) {
                         XObject argVal = (funcExtFunction.getArg(idx)).execute(xctxt);
-                        argSequence.add(XSDate.parseDate(argVal.str()));
+                        argSequence.add(XSDate.parseDate(getSimpleStrVal(argVal)));
                     }
 
                     ResultSequence rSeq = (new XSDate()).constructor(argSequence); 
@@ -160,5 +165,22 @@ public class XSConstructorFunctionUtil {
         return evalResult;
         
     }
+    
+    /*
+     * Given an XObject object reference, return the string value
+     * of this object. 
+     */
+    private static String getSimpleStrVal(XObject xObj) {
+       String strVal = null;
+       
+       if (xObj instanceof XSAnyType) {
+          strVal = ((XSAnyType)xObj).stringValue();    
+       }
+       else {
+          strVal = xObj.str();  
+       }
+       
+       return strVal;
+    }
 
 }
diff --git a/src/org/apache/xalan/xslt/util/XPathSequenceHelper.java b/src/org/apache/xalan/xslt/util/XslTransformEvaluationHelper.java
similarity index 63%
rename from src/org/apache/xalan/xslt/util/XPathSequenceHelper.java
rename to src/org/apache/xalan/xslt/util/XslTransformEvaluationHelper.java
index 3b905398..7feef9b8 100644
--- a/src/org/apache/xalan/xslt/util/XPathSequenceHelper.java
+++ b/src/org/apache/xalan/xslt/util/XslTransformEvaluationHelper.java
@@ -19,15 +19,19 @@ package org.apache.xalan.xslt.util;
 import org.apache.xpath.objects.ResultSequence;
 import org.apache.xpath.objects.XObject;
 
+import java.util.List;
+
+import org.apache.xalan.templates.XMLNSDecl;
+
 /**
- * This class, has few utility methods, to help process the XPath 
- * data model sequences.
+ * This class, has few utility methods, to help with certain 
+ * XalanJ XSLT transformation implementation tasks.
  * 
  * @author Mukul Gandhi <mu...@apache.org>
  * 
  * @xsl.usage advanced
  */
-public class XPathSequenceHelper {
+public class XslTransformEvaluationHelper {
     
     /**
      * Given an XDM input sequence, expand that sequence to produce a new sequence
@@ -49,5 +53,24 @@ public class XPathSequenceHelper {
           }
        }
     }
+    
+    /**
+     * Given an XPath expression string, replace XML namespace uri references within it,
+     * with the corresponding declared XML namespace prefixes, using information from
+     * the list object 'nsPrefixTable' passed to this method.
+     */
+    public static String replaceNsUrisWithPrefixesOnXPathStr(String xpathExprStr, 
+                                                                          List<XMLNSDecl> nsPrefixTable) {
+       String replacedXPathExprStr = xpathExprStr;
+       
+       for (int idx = 0; idx < nsPrefixTable.size(); idx++) {
+          XMLNSDecl xmlNSDecl = nsPrefixTable.get(idx);
+          String prefix = xmlNSDecl.getPrefix();
+          String uri = xmlNSDecl.getURI();
+          replacedXPathExprStr = replacedXPathExprStr.replace(uri + ":", prefix + ":");
+       }
+       
+       return replacedXPathExprStr; 
+    }
 
 }
diff --git a/src/org/apache/xpath/composite/ForExpr.java b/src/org/apache/xpath/composite/ForExpr.java
index ea2fbdbe..97ea4b34 100644
--- a/src/org/apache/xpath/composite/ForExpr.java
+++ b/src/org/apache/xpath/composite/ForExpr.java
@@ -25,7 +25,9 @@ import java.util.Vector;
 import javax.xml.transform.SourceLocator;
 import javax.xml.transform.TransformerException;
 
-import org.apache.xalan.xslt.util.XPathSequenceHelper;
+import org.apache.xalan.templates.ElemTemplateElement;
+import org.apache.xalan.templates.XMLNSDecl;
+import org.apache.xalan.xslt.util.XslTransformEvaluationHelper;
 import org.apache.xml.dtm.DTM;
 import org.apache.xml.dtm.DTMIterator;
 import org.apache.xml.utils.QName;
@@ -80,7 +82,19 @@ public class ForExpr extends Expression {
        
        SourceLocator srcLocator = xctxt.getSAXLocator();
        
-       XPath returnExprXpath = new XPath(fReturnExprXPathStr, srcLocator, null, XPath.SELECT, null);
+       ElemTemplateElement elemTemplateElement = (ElemTemplateElement)xctxt.getNamespaceContext();
+       List<XMLNSDecl> prefixTable = null;
+       if (elemTemplateElement != null) {
+          prefixTable = (List<XMLNSDecl>)elemTemplateElement.getPrefixTable();
+       }
+       
+       if (prefixTable != null) {
+          fReturnExprXPathStr = XslTransformEvaluationHelper.replaceNsUrisWithPrefixesOnXPathStr(
+                                                                                       fReturnExprXPathStr, prefixTable);
+       }
+       
+       XPath returnExprXpath = new XPath(fReturnExprXPathStr, srcLocator, xctxt.getNamespaceContext(), 
+                                                                                               XPath.SELECT, null);
        
        ResultSequence resultSeq = getForExpressionEvalResult(fForExprVarBindingList.listIterator(), 
                                                                             returnExprXpath, xctxt);       
@@ -88,7 +102,7 @@ public class ForExpr extends Expression {
        // An xdm sequence object 'resultSeq', may have items that are themselves sequence 
        // objects. We need to expand such nested sequence objects, to get a final sequence
        // none of whose items are sequence with cardinality greater than one.   
-       XPathSequenceHelper.expandResultSequence(resultSeq, finalResultSeq);
+       XslTransformEvaluationHelper.expandResultSequence(resultSeq, finalResultSeq);
                
        m_xpathVarList.clear();
        
@@ -145,7 +159,19 @@ public class ForExpr extends Expression {
            String varName = forExprVarBinding.getVarName();
            String varBindingXPathStr = forExprVarBinding.getXpathExprStr();
            
-           XPath varBindingXpath = new XPath(varBindingXPathStr, srcLocator, null, XPath.SELECT, null);
+           ElemTemplateElement elemTemplateElement = (ElemTemplateElement)xctxt.getNamespaceContext();
+           List<XMLNSDecl> prefixTable = null;
+           if (elemTemplateElement != null) {
+              prefixTable = (List<XMLNSDecl>)elemTemplateElement.getPrefixTable();
+           }
+           
+           if (prefixTable != null) {
+              varBindingXPathStr = XslTransformEvaluationHelper.replaceNsUrisWithPrefixesOnXPathStr(
+                                                                                            varBindingXPathStr, prefixTable);
+           }
+           
+           XPath varBindingXpath = new XPath(varBindingXPathStr, srcLocator, xctxt.getNamespaceContext(), 
+                                                                                                 XPath.SELECT, null);
            if (fVars != null) {
               if (!m_xpathVarList.contains(new QName(varName))) {
                  m_xpathVarList.add(new QName(varName));
@@ -153,7 +179,7 @@ public class ForExpr extends Expression {
               varBindingXpath.fixupVariables(fVars, fGlobalsSize);
            }
            
-           XObject xsObj = varBindingXpath.execute(xctxt, contextNode, null);
+           XObject xsObj = varBindingXpath.execute(xctxt, contextNode, xctxt.getNamespaceContext());
            
            ResultSequence xsObjResultSeq = new ResultSequence(); 
            
@@ -213,7 +239,8 @@ public class ForExpr extends Expression {
                returnExprXpath.fixupVariables(fVars, fGlobalsSize);
             }
             
-            XObject retExprValue = returnExprXpath.execute(xctxt, contextNode, null);
+            XObject retExprValue = returnExprXpath.execute(xctxt, contextNode, 
+                                                                        xctxt.getNamespaceContext());
             resultSeq.add(retExprValue);
             
             return resultSeq; 
diff --git a/src/org/apache/xpath/composite/IfExpr.java b/src/org/apache/xpath/composite/IfExpr.java
index 3dabbc47..b06399c1 100644
--- a/src/org/apache/xpath/composite/IfExpr.java
+++ b/src/org/apache/xpath/composite/IfExpr.java
@@ -16,11 +16,15 @@
  */
 package org.apache.xpath.composite;
 
+import java.util.List;
 import java.util.Vector;
 
 import javax.xml.transform.SourceLocator;
 import javax.xml.transform.TransformerException;
 
+import org.apache.xalan.templates.ElemTemplateElement;
+import org.apache.xalan.templates.XMLNSDecl;
+import org.apache.xalan.xslt.util.XslTransformEvaluationHelper;
 import org.apache.xpath.Expression;
 import org.apache.xpath.ExpressionOwner;
 import org.apache.xpath.XPath;
@@ -95,29 +99,52 @@ public class IfExpr extends Expression {
        
        int contextNode = xctxt.getContextNode();
        
-       XPath conditionlExprXpath = new XPath(conditionalExprXPathStr, srcLocator, null, 
-                                                                            XPath.SELECT, null);
+       ElemTemplateElement elemTemplateElement = (ElemTemplateElement)xctxt.getNamespaceContext();
+       List<XMLNSDecl> prefixTable = null;
+       if (elemTemplateElement != null) {
+          prefixTable = (List<XMLNSDecl>)elemTemplateElement.getPrefixTable();
+       }
+       
+       if (prefixTable != null) {
+          conditionalExprXPathStr = XslTransformEvaluationHelper.replaceNsUrisWithPrefixesOnXPathStr(
+                                                                                    conditionalExprXPathStr, prefixTable);
+       }
+       
+       XPath conditionlExprXpath = new XPath(conditionalExprXPathStr, srcLocator, xctxt.getNamespaceContext(), 
+                                                                                                 XPath.SELECT, null);
        if (fVars != null) {
           conditionlExprXpath.fixupVariables(fVars, fGlobalsSize);
        }
        
-       XObject conditionalXpathExprResult = conditionlExprXpath.execute(xctxt, contextNode, null);
+       XObject conditionalXpathExprResult = conditionlExprXpath.execute(xctxt, contextNode, xctxt.getNamespaceContext());
        
        if (conditionalXpathExprResult.bool()) {
-           XPath thenExprXpath = new XPath(thenExprXPathStr, srcLocator, null, XPath.SELECT, null);
+           if (prefixTable != null) {
+              thenExprXPathStr = XslTransformEvaluationHelper.replaceNsUrisWithPrefixesOnXPathStr(
+                                                                                        thenExprXPathStr, prefixTable);
+           }
+           
+           XPath thenExprXpath = new XPath(thenExprXPathStr, srcLocator, xctxt.getNamespaceContext(), 
+                                                                                               XPath.SELECT, null);
            if (fVars != null) {
               thenExprXpath.fixupVariables(fVars, fGlobalsSize);
            }
            
-           evalResult = thenExprXpath.execute(xctxt, contextNode, null);
+           evalResult = thenExprXpath.execute(xctxt, contextNode, xctxt.getNamespaceContext());
        }
        else {
-           XPath elseExprXpath = new XPath(elseExprXPathStr, srcLocator, null, XPath.SELECT, null);
+           if (prefixTable != null) {
+              elseExprXPathStr = XslTransformEvaluationHelper.replaceNsUrisWithPrefixesOnXPathStr(elseExprXPathStr, 
+                                                                                                          prefixTable);
+           }
+           
+           XPath elseExprXpath = new XPath(elseExprXPathStr, srcLocator, xctxt.getNamespaceContext(), 
+                                                                                              XPath.SELECT, null);
            if (fVars != null) {
               elseExprXpath.fixupVariables(fVars, fGlobalsSize);
            }
            
-           evalResult = elseExprXpath.execute(xctxt, contextNode, null);
+           evalResult = elseExprXpath.execute(xctxt, contextNode, xctxt.getNamespaceContext());
        }
        
        return evalResult;
diff --git a/src/org/apache/xpath/composite/LetExpr.java b/src/org/apache/xpath/composite/LetExpr.java
index 8d3868d4..e36f364e 100644
--- a/src/org/apache/xpath/composite/LetExpr.java
+++ b/src/org/apache/xpath/composite/LetExpr.java
@@ -24,6 +24,9 @@ import java.util.Vector;
 import javax.xml.transform.SourceLocator;
 import javax.xml.transform.TransformerException;
 
+import org.apache.xalan.templates.ElemTemplateElement;
+import org.apache.xalan.templates.XMLNSDecl;
+import org.apache.xalan.xslt.util.XslTransformEvaluationHelper;
 import org.apache.xml.utils.QName;
 import org.apache.xpath.Expression;
 import org.apache.xpath.ExpressionOwner;
@@ -80,32 +83,48 @@ public class LetExpr extends Expression {
        
        Map<QName, XObject> xpathVarMap = xctxt.getXPathVarMap();
        
+       ElemTemplateElement elemTemplateElement = (ElemTemplateElement)xctxt.getNamespaceContext();
+       List<XMLNSDecl> prefixTable = null;
+       if (elemTemplateElement != null) {
+          prefixTable = (List<XMLNSDecl>)elemTemplateElement.getPrefixTable();
+       }
+       
        for (int idx = 0; idx < fLetExprVarBindingList.size(); idx++) {
           LetExprVarBinding letExprVarBinding = fLetExprVarBindingList.get(idx);
           String varName = letExprVarBinding.getVarName();
           String fXpathExprStr = letExprVarBinding.getXpathExprStr();
           
-          XPath letExprVarBindingXpath = new XPath(fXpathExprStr, srcLocator, null, 
-                                                                        XPath.SELECT, null);
+          if (prefixTable != null) {
+             fXpathExprStr = XslTransformEvaluationHelper.replaceNsUrisWithPrefixesOnXPathStr(
+                                                                                  fXpathExprStr, prefixTable);
+          }
+          
+          XPath letExprVarBindingXpath = new XPath(fXpathExprStr, srcLocator, xctxt.getNamespaceContext(), 
+                                                                                             XPath.SELECT, null);
           if (fVars != null) {
              letExprVarBindingXpath.fixupVariables(fVars, fGlobalsSize);
           }
           
           XObject varBindingEvalResult = letExprVarBindingXpath.execute(xctxt, contextNode, 
-                                                                                       null);
+                                                                                     xctxt.getNamespaceContext());
           
           m_xpathVarList.add(new QName(varName));
           xpathVarMap.put(new QName(varName), varBindingEvalResult);
        }
        
-       XPath returnExprXpath = new XPath(fReturnExprXPathStr, srcLocator, null, 
-                                                                            XPath.SELECT, null);
+       if (prefixTable != null) {
+          fReturnExprXPathStr = XslTransformEvaluationHelper.replaceNsUrisWithPrefixesOnXPathStr(
+                                                                                fReturnExprXPathStr, prefixTable);
+       }
+       
+       XPath returnExprXpath = new XPath(fReturnExprXPathStr, srcLocator, xctxt.getNamespaceContext(), 
+                                                                                             XPath.SELECT, null);
        
        if (fVars != null) {
           returnExprXpath.fixupVariables(fVars, fGlobalsSize);
        }
        
-       evalResult = returnExprXpath.execute(xctxt, contextNode, null);
+       evalResult = returnExprXpath.execute(xctxt, contextNode, xctxt.getNamespaceContext());
        
        if (evalResult == null) {
           // return an empty sequence, here
diff --git a/src/org/apache/xpath/composite/QuantifiedExpr.java b/src/org/apache/xpath/composite/QuantifiedExpr.java
index b644979c..d6e4357d 100644
--- a/src/org/apache/xpath/composite/QuantifiedExpr.java
+++ b/src/org/apache/xpath/composite/QuantifiedExpr.java
@@ -25,6 +25,9 @@ import java.util.Vector;
 import javax.xml.transform.SourceLocator;
 import javax.xml.transform.TransformerException;
 
+import org.apache.xalan.templates.ElemTemplateElement;
+import org.apache.xalan.templates.XMLNSDecl;
+import org.apache.xalan.xslt.util.XslTransformEvaluationHelper;
 import org.apache.xml.dtm.DTM;
 import org.apache.xml.dtm.DTMIterator;
 import org.apache.xml.utils.QName;
@@ -88,7 +91,19 @@ public class QuantifiedExpr extends Expression {
         
         SourceLocator srcLocator = xctxt.getSAXLocator();
         
-        XPath quantifiedExprXpath = new XPath(fQuantifierTestXPathStr, srcLocator, null, XPath.SELECT, null);
+        ElemTemplateElement elemTemplateElement = (ElemTemplateElement)xctxt.getNamespaceContext();
+        List<XMLNSDecl> prefixTable = null;
+        if (elemTemplateElement != null) {
+            prefixTable = (List<XMLNSDecl>)elemTemplateElement.getPrefixTable();
+        }
+        
+        if (prefixTable != null) {
+            fQuantifierTestXPathStr = XslTransformEvaluationHelper.replaceNsUrisWithPrefixesOnXPathStr(
+                                                                                          fQuantifierTestXPathStr, prefixTable);
+        }
+        
+        XPath quantifiedExprXpath = new XPath(fQuantifierTestXPathStr, srcLocator, xctxt.getNamespaceContext(), 
+                                                                                                        XPath.SELECT, null);
         
         ResultSequence resultSequence = getQuantifiedExpressionEvalResult(fQuantifiedExprVarBindingList.listIterator(), 
                                                                                                  quantifiedExprXpath, xctxt);
@@ -180,15 +195,27 @@ public class QuantifiedExpr extends Expression {
         
         Map<QName, XObject> quantifiedExprVarBindingMap = xctxt.getXPathVarMap();
         
+        ElemTemplateElement elemTemplateElement = (ElemTemplateElement)xctxt.getNamespaceContext();
+        List<XMLNSDecl> prefixTable = null;
+        if (elemTemplateElement != null) {
+            prefixTable = (List<XMLNSDecl>)elemTemplateElement.getPrefixTable();
+        }
+        
         if (listIter.hasNext()) {           
            ForQuantifiedExprVarBinding quantifiedExprVarBinding = (ForQuantifiedExprVarBinding)listIter.next();            
             
            // evaluate the current, variable binding xpath expression
            
            String varName = quantifiedExprVarBinding.getVarName();
-           String varBindingXPathStr = quantifiedExprVarBinding.getXpathExprStr();
+           String varBindingXPathStr = quantifiedExprVarBinding.getXpathExprStr();                      
+           
+           if (prefixTable != null) {
+               varBindingXPathStr = XslTransformEvaluationHelper.replaceNsUrisWithPrefixesOnXPathStr(
+                                                                                        varBindingXPathStr, prefixTable);
+           }
            
-           XPath varBindingXpath = new XPath(varBindingXPathStr, srcLocator, null, XPath.SELECT, null);
+           XPath varBindingXpath = new XPath(varBindingXPathStr, srcLocator, xctxt.getNamespaceContext(), 
+                                                                                                   XPath.SELECT, null);
            if (fVars != null) {
               if (!m_xpathVarList.contains(new QName(varName))) {
                  m_xpathVarList.add(new QName(varName));
@@ -196,7 +223,7 @@ public class QuantifiedExpr extends Expression {
               varBindingXpath.fixupVariables(fVars, fGlobalsSize);
            }
            
-           XObject xsObj = varBindingXpath.execute(xctxt, contextNode, null);
+           XObject xsObj = varBindingXpath.execute(xctxt, contextNode, xctxt.getNamespaceContext());
            
            ResultSequence xsObjResultSeq = new ResultSequence(); 
            
@@ -253,7 +280,8 @@ public class QuantifiedExpr extends Expression {
                quantifiedExprXpath.fixupVariables(fVars, fGlobalsSize);
             }
             
-            XObject quantifiedTestExprValue = quantifiedExprXpath.execute(xctxt, contextNode, null);            
+            XObject quantifiedTestExprValue = quantifiedExprXpath.execute(xctxt, contextNode, 
+                                                                                     xctxt.getNamespaceContext());            
             
             resultSeq.add(new XSBoolean(quantifiedTestExprValue.bool()));
             
diff --git a/src/org/apache/xpath/composite/SimpleSequenceConstructor.java b/src/org/apache/xpath/composite/SimpleSequenceConstructor.java
index b2dddbef..8ebaa471 100644
--- a/src/org/apache/xpath/composite/SimpleSequenceConstructor.java
+++ b/src/org/apache/xpath/composite/SimpleSequenceConstructor.java
@@ -23,6 +23,9 @@ import java.util.Vector;
 import javax.xml.transform.SourceLocator;
 import javax.xml.transform.TransformerException;
 
+import org.apache.xalan.templates.ElemTemplateElement;
+import org.apache.xalan.templates.XMLNSDecl;
+import org.apache.xalan.xslt.util.XslTransformEvaluationHelper;
 import org.apache.xml.dtm.DTM;
 import org.apache.xml.dtm.DTMIterator;
 import org.apache.xml.dtm.DTMManager;
@@ -77,6 +80,12 @@ public class SimpleSequenceConstructor extends Expression {
         
         int contextNode = xctxt.getContextNode();
         
+        ElemTemplateElement elemTemplateElement = (ElemTemplateElement)xctxt.getNamespaceContext();
+        List<XMLNSDecl> prefixTable = null;
+        if (elemTemplateElement != null) {
+            prefixTable = (List<XMLNSDecl>)elemTemplateElement.getPrefixTable();
+        }
+        
         // We evaluate below all the, XPath expression parts within the list 
         // 'sequenceConstructorXPathParts', and concatenate the sequences resulting
         // from each of them, to get the final result sequence that is returned by
@@ -84,12 +93,17 @@ public class SimpleSequenceConstructor extends Expression {
         for (int idx = 0; idx < sequenceConstructorXPathParts.size(); idx++) {
            String xpathExprStr = sequenceConstructorXPathParts.get(idx);
            
-           XPath xpathObj = new XPath(xpathExprStr, srcLocator, null, XPath.SELECT, null);
+           if (prefixTable != null) {
+              xpathExprStr = XslTransformEvaluationHelper.replaceNsUrisWithPrefixesOnXPathStr(xpathExprStr, 
+                                                                                                     prefixTable);
+           }
+           
+           XPath xpathObj = new XPath(xpathExprStr, srcLocator, xctxt.getNamespaceContext(), XPath.SELECT, null);
            if (fVars != null) {
-               xpathObj.fixupVariables(fVars, fGlobalsSize);
+              xpathObj.fixupVariables(fVars, fGlobalsSize);
            }
 
-           XObject xPathExprPartResult = xpathObj.execute(xctxt, contextNode, null);
+           XObject xPathExprPartResult = xpathObj.execute(xctxt, contextNode, xctxt.getNamespaceContext());
            
            if (xPathExprPartResult instanceof XNodeSet) {
                DTMManager dtmMgr = (DTMManager)xctxt;
diff --git a/src/org/apache/xpath/functions/DynamicFunctionCall.java b/src/org/apache/xpath/functions/DynamicFunctionCall.java
index 659dcb78..24e843e3 100644
--- a/src/org/apache/xpath/functions/DynamicFunctionCall.java
+++ b/src/org/apache/xpath/functions/DynamicFunctionCall.java
@@ -24,7 +24,10 @@ import javax.xml.transform.SourceLocator;
 import javax.xml.transform.TransformerException;
 
 import org.apache.xalan.extensions.ExpressionContext;
+import org.apache.xalan.templates.ElemTemplateElement;
 import org.apache.xalan.templates.StylesheetRoot;
+import org.apache.xalan.templates.XMLNSDecl;
+import org.apache.xalan.xslt.util.XslTransformEvaluationHelper;
 import org.apache.xml.utils.QName;
 import org.apache.xpath.Expression;
 import org.apache.xpath.ExpressionNode;
@@ -130,22 +133,41 @@ public class DynamicFunctionCall extends Expression {
                                                        + "Number of arguments provided " + argList.size() + ".", xctxt.getSAXLocator());    
            }
            
+           ElemTemplateElement elemTemplateElement = (ElemTemplateElement)xctxt.getNamespaceContext();
+           List<XMLNSDecl> prefixTable = null;
+           if (elemTemplateElement != null) {
+               prefixTable = (List<XMLNSDecl>)elemTemplateElement.getPrefixTable();
+           }
+           
            for (int idx = 0; idx < funcParamNameList.size(); idx++) {              
               String funcParamName = funcParamNameList.get(idx);
               
               String argXPathStr = argList.get(idx);
               
-              XPath argXpath = new XPath(argXPathStr, srcLocator, null, XPath.SELECT, null);
+              if (prefixTable != null) {
+                  argXPathStr = XslTransformEvaluationHelper.replaceNsUrisWithPrefixesOnXPathStr(argXPathStr, 
+                                                                                                      prefixTable);
+              }
+              
+              XPath argXpath = new XPath(argXPathStr, srcLocator, xctxt.getNamespaceContext(), 
+                                                                                        XPath.SELECT, null);
               if (fVars != null) {
                  argXpath.fixupVariables(fVars, fGlobalsSize);
               }
-              XObject argValue = argXpath.execute(xctxt, contextNode, null);
+              
+              XObject argValue = argXpath.execute(xctxt, contextNode, xctxt.getNamespaceContext());
               
               inlineFunctionVarMap.put(new QName(funcParamName), argValue);
            }
            
-           XPath inlineFnXpath = new XPath(inlineFnXpathStr, srcLocator, null, XPath.SELECT, null);
-           evalResult = inlineFnXpath.execute(xctxt, contextNode, null);
+           if (prefixTable != null) {
+               inlineFnXpathStr = XslTransformEvaluationHelper.replaceNsUrisWithPrefixesOnXPathStr(inlineFnXpathStr, 
+                                                                                                           prefixTable);
+           }
+           
+           XPath inlineFnXpath = new XPath(inlineFnXpathStr, srcLocator, xctxt.getNamespaceContext(), 
+                                                                                       XPath.SELECT, null);
+           evalResult = inlineFnXpath.execute(xctxt, contextNode, xctxt.getNamespaceContext());
            
            inlineFunctionVarMap.clear();           
        }
diff --git a/src/org/apache/xpath/functions/FuncExtFunction.java b/src/org/apache/xpath/functions/FuncExtFunction.java
index d4a792e3..27baee47 100644
--- a/src/org/apache/xpath/functions/FuncExtFunction.java
+++ b/src/org/apache/xpath/functions/FuncExtFunction.java
@@ -22,7 +22,11 @@ package org.apache.xpath.functions;
 
 import java.util.Vector;
 
+import javax.xml.XMLConstants;
+import javax.xml.transform.TransformerException;
+
 import org.apache.xalan.res.XSLMessages;
+import org.apache.xalan.templates.XSConstructorFunctionUtil;
 import org.apache.xpath.Expression;
 import org.apache.xpath.ExpressionNode;
 import org.apache.xpath.ExpressionOwner;
@@ -33,6 +37,7 @@ import org.apache.xpath.objects.XNull;
 import org.apache.xpath.objects.XObject;
 import org.apache.xpath.res.XPATHErrorResources;
 import org.apache.xpath.res.XPATHMessages;
+import org.xml.sax.SAXException;
 
 /**
  * An object of this class represents an extension call expression.  When
@@ -188,7 +193,28 @@ public class FuncExtFunction extends Function
           XPATHErrorResources.ER_EXTENSION_FUNCTION_CANNOT_BE_INVOKED,
           new Object[] {toString()}));
       
-    XObject result;
+    XObject result = null;
+    
+    if (XMLConstants.W3C_XML_SCHEMA_NS_URI.equals(this.getNamespace())) {
+       // An XPath 3.1 constructor function call, is syntactically similar
+       // to XalanJ extension function call (both have, syntax like 
+       // nsPrefix:functionName(..)). If the XML namespace of XPath function 
+       // call is http://www.w3.org/2001/XMLSchema, this class implements that
+       // as an XPath 3.1 constructor function call within this section of code.
+       try {
+          result = XSConstructorFunctionUtil.processFuncExtFunctionOrXPathOpn(
+                                                                        xctxt, this);
+       } 
+       catch (TransformerException ex) {        
+          throw new TransformerException(ex.getMessage(), xctxt.getSAXLocator());
+       } 
+       catch (SAXException ex) {        
+          throw new TransformerException(ex.getMessage(), xctxt.getSAXLocator());
+       }
+       
+       return result;
+    }
+    
     Vector argVec = new Vector();
     int nArgs = m_argVec.size();
 
diff --git a/src/org/apache/xpath/operations/Mult.java b/src/org/apache/xpath/operations/Mult.java
index a42502b7..e4992787 100644
--- a/src/org/apache/xpath/operations/Mult.java
+++ b/src/org/apache/xpath/operations/Mult.java
@@ -77,6 +77,16 @@ public class Mult extends Operation
           double rDouble = ((XNumber)right).num();
           result = new XNumber(lDouble * rDouble);          
       }
+      else if ((left instanceof XSInteger) && (right instanceof XSDouble)) {
+          double lDouble = (((XSInteger)left).intValue()).doubleValue();
+          double rDouble = ((XSDouble)right).doubleValue();
+          result = new XNumber(lDouble * rDouble); 
+      }
+      else if ((left instanceof XSDouble) && (right instanceof XSInteger)) {
+          double lDouble = ((XSDouble)left).doubleValue();
+          double rDouble = (((XSInteger)right).intValue()).doubleValue();
+          result = new XNumber(lDouble * rDouble); 
+      }
       else {
           result = new XNumber(left.num() * right.num());
       }
diff --git a/src/org/apache/xpath/operations/Operation.java b/src/org/apache/xpath/operations/Operation.java
index d411945c..65f070d8 100644
--- a/src/org/apache/xpath/operations/Operation.java
+++ b/src/org/apache/xpath/operations/Operation.java
@@ -20,11 +20,16 @@
  */
 package org.apache.xpath.operations;
 
+import javax.xml.XMLConstants;
+
+import org.apache.xalan.templates.XSConstructorFunctionUtil;
 import org.apache.xpath.Expression;
 import org.apache.xpath.ExpressionOwner;
 import org.apache.xpath.XPathContext;
 import org.apache.xpath.XPathVisitor;
+import org.apache.xpath.functions.FuncExtFunction;
 import org.apache.xpath.objects.XObject;
+import org.xml.sax.SAXException;
 
 /**
  * The baseclass for a binary operation.
@@ -105,13 +110,53 @@ public class Operation extends Expression implements ExpressionOwner
   public XObject execute(XPathContext xctxt)
           throws javax.xml.transform.TransformerException
   {
-
-    XObject left = m_left.execute(xctxt, true);
-    XObject right = m_right.execute(xctxt, true);
+    
+    // XObject left = m_left.execute(xctxt, true);
+    // XObject right = m_right.execute(xctxt, true);
+      
+    XObject left = null;
+    
+    XObject right = null;
+    
+    try {
+        if (m_left instanceof FuncExtFunction) {
+           FuncExtFunction extFunction = (FuncExtFunction)m_left;
+           if (XMLConstants.W3C_XML_SCHEMA_NS_URI.equals(extFunction.getNamespace())) {
+              left = XSConstructorFunctionUtil.processFuncExtFunctionOrXPathOpn(
+                                                                             xctxt, m_left); 
+           }
+           else {
+              left = m_left.execute(xctxt, true);  
+           }
+        }
+        else {
+           left = m_left.execute(xctxt, true); 
+        }
+        
+        if (m_right instanceof FuncExtFunction) {
+           FuncExtFunction extFunction = (FuncExtFunction)m_right;
+           if (XMLConstants.W3C_XML_SCHEMA_NS_URI.equals(extFunction.getNamespace())) {
+              right = XSConstructorFunctionUtil.processFuncExtFunctionOrXPathOpn(
+                                                                            xctxt, m_right); 
+           }
+           else {
+              right = m_right.execute(xctxt, true);  
+           }
+        }
+        else {
+           right = m_right.execute(xctxt, true); 
+        }
+    }
+    catch (SAXException ex) {
+       throw new javax.xml.transform.TransformerException(ex.getMessage(), 
+                                                                    xctxt.getSAXLocator()); 
+    }
 
     XObject result = operate(left, right);
+    
     left.detach();
     right.detach();
+    
     return result;
   }
 
diff --git a/src/org/apache/xpath/operations/Range.java b/src/org/apache/xpath/operations/Range.java
index b728f2df..a994b942 100644
--- a/src/org/apache/xpath/operations/Range.java
+++ b/src/org/apache/xpath/operations/Range.java
@@ -22,10 +22,16 @@ package org.apache.xpath.operations;
 
 import java.math.BigInteger;
 
+import javax.xml.XMLConstants;
+
+import org.apache.xalan.templates.XSConstructorFunctionUtil;
 import org.apache.xpath.XPathContext;
+import org.apache.xpath.functions.FuncExtFunction;
 import org.apache.xpath.objects.ResultSequence;
 import org.apache.xpath.objects.XObject;
 import org.apache.xpath.xs.types.XSInteger;
+import org.apache.xpath.xs.types.XSNumericType;
+import org.xml.sax.SAXException;
 
 /**
  * The XPath 3.1 range "to" operation.
@@ -57,22 +63,57 @@ public class Range extends Operation
     public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException {
         
       ResultSequence result = new ResultSequence();
-  
-      XObject expr1 = m_left.execute(xctxt);
       
-      XObject expr2 = m_right.execute(xctxt);
+      XObject expr1 = null;
+      
+      XObject expr2 = null;
       
-      double firstArg = expr1.num();
-      double secondArg = expr2.num();
+      try {
+          if (m_left instanceof FuncExtFunction) {
+             FuncExtFunction extFunction = (FuncExtFunction)m_left;
+             if (XMLConstants.W3C_XML_SCHEMA_NS_URI.equals(extFunction.getNamespace())) {
+                 expr1 = XSConstructorFunctionUtil.processFuncExtFunctionOrXPathOpn(xctxt, m_left); 
+             }
+             else {
+                 expr1 = m_left.execute(xctxt, true);  
+             }
+          }
+          else {
+              expr1 = m_left.execute(xctxt, true); 
+          }
+          
+          if (m_right instanceof FuncExtFunction) {
+             FuncExtFunction extFunction = (FuncExtFunction)m_right;
+             if (XMLConstants.W3C_XML_SCHEMA_NS_URI.equals(extFunction.getNamespace())) {
+                 expr2 = XSConstructorFunctionUtil.processFuncExtFunctionOrXPathOpn(xctxt, m_right); 
+             }
+             else {
+                 expr2 = m_right.execute(xctxt, true);  
+             }
+          }
+          else {
+              expr2 = m_right.execute(xctxt, true); 
+          }
+      }
+      catch (SAXException ex) {
+         throw new javax.xml.transform.TransformerException(ex.getMessage(), xctxt.getSAXLocator()); 
+      }
       
+      double firstArg = (expr1 instanceof XSNumericType) ?  (Double.valueOf((
+                                                                       (XSNumericType)expr1).stringValue())).doubleValue() : expr1.num();  
+      double secondArg = (expr2 instanceof XSNumericType) ?  (Double.valueOf((
+                                                                       (XSNumericType)expr2).stringValue())).doubleValue() : expr2.num();
+              
       if (firstArg > (long)firstArg) {
          throw new javax.xml.transform.TransformerException("XPTY0004 : The required item type of the first operand of "
-                                                     + "'to' is an xs:integer. The supplied value is of type xs:double.", xctxt.getSAXLocator());  
+                                                     + "'to' is an xs:integer. The supplied value is of type xs:double.", 
+                                                                                                                   xctxt.getSAXLocator());  
       }
       
       if (secondArg > (long)secondArg) {
          throw new javax.xml.transform.TransformerException("XPTY0004 : The required item type of the second operand of "
-                                                     + "'to' is an xs:integer. The supplied value is of type xs:double.", xctxt.getSAXLocator());  
+                                                     + "'to' is an xs:integer. The supplied value is of type xs:double.", 
+                                                                                                                   xctxt.getSAXLocator());  
       }
       
       long fromIdx = (long)firstArg;
diff --git a/tests/for_expr/gold/test10.out b/tests/for_expr/gold/test10.out
new file mode 100644
index 00000000..89c6e00f
--- /dev/null
+++ b/tests/for_expr/gold/test10.out
@@ -0,0 +1 @@
+<?xml version="1.0" encoding="UTF-8"?><result>8.414709848078965 9.092974268256818 1.4112000805986722 -7.5680249530792825 -9.589242746631385</result>
diff --git a/tests/for_expr/gold/test8.out b/tests/for_expr/gold/test8.out
new file mode 100644
index 00000000..1b5a2029
--- /dev/null
+++ b/tests/for_expr/gold/test8.out
@@ -0,0 +1 @@
+<?xml version="1.0" encoding="UTF-8"?><result>0.8414709848078965 0.9092974268256817 0.1411200080598672 -0.7568024953079282 -0.9589242746631385</result>
diff --git a/tests/for_expr/gold/test9.out b/tests/for_expr/gold/test9.out
new file mode 100644
index 00000000..89c6e00f
--- /dev/null
+++ b/tests/for_expr/gold/test9.out
@@ -0,0 +1 @@
+<?xml version="1.0" encoding="UTF-8"?><result>8.414709848078965 9.092974268256818 1.4112000805986722 -7.5680249530792825 -9.589242746631385</result>
diff --git a/tests/let_expr/test3.xsl b/tests/for_expr/test10.xsl
similarity index 54%
copy from tests/let_expr/test3.xsl
copy to tests/for_expr/test10.xsl
index fb97834d..53aa9b46 100644
--- a/tests/let_expr/test3.xsl
+++ b/tests/for_expr/test10.xsl
@@ -1,24 +1,23 @@
 <?xml version="1.0"?>
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                xmlns:xs="http://www.w3.org/2001/XMLSchema"
+                xmlns:math="http://www.w3.org/2005/xpath-functions/math"
+                exclude-result-prefixes="xs math"
                 version="3.0">
                 
    <!-- Author: mukulg@apache.org -->
    
-   <!-- use with test1_a.xml -->
-   
-   <!-- An XSLT stylesheet test, for the XPath 3.1 "let" expression.
-        
-        This XSLT stylesheet, borrows an XPath "let" expression example 
-        from https://www.altova.com/, with slight modifications. -->                
+   <!-- This XSLT stylesheet test, illustrates an XPath 3.1 "for" 
+        expression evaluation, with XML namespace references within
+        the XPath "for" expression's variable binding and return 
+        expressions. -->                   
+
+   <xsl:output method="xml" indent="yes"/>
 
-   <xsl:output method="text"/>
-                                            
-   <xsl:template match="/company">                                                 
-      <xsl:variable name="officeDataInfo" select="let $x := office[@location = 'Boston'],
-                                                     $y := office[@location = 'Vienna']
-                                                     return concat('(a) Boston employee count : ', count($x/employee), 
-                                                                   ' (b) Vienna employee count : ', count($y/employee))"/>
-      <xsl:value-of select="$officeDataInfo"/>
+   <xsl:template match="/">
+      <result>
+         <xsl:value-of select="for $a in (xs:integer(1) to xs:integer(5)) return 10 * math:sin($a)"/>
+      </result>
    </xsl:template>
    
    <!--
diff --git a/tests/let_expr/test3.xsl b/tests/for_expr/test8.xsl
similarity index 54%
copy from tests/let_expr/test3.xsl
copy to tests/for_expr/test8.xsl
index fb97834d..0aede058 100644
--- a/tests/let_expr/test3.xsl
+++ b/tests/for_expr/test8.xsl
@@ -1,24 +1,21 @@
 <?xml version="1.0"?>
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                xmlns:math="http://www.w3.org/2005/xpath-functions/math"
+                exclude-result-prefixes="math"
                 version="3.0">
                 
    <!-- Author: mukulg@apache.org -->
    
-   <!-- use with test1_a.xml -->
-   
-   <!-- An XSLT stylesheet test, for the XPath 3.1 "let" expression.
-        
-        This XSLT stylesheet, borrows an XPath "let" expression example 
-        from https://www.altova.com/, with slight modifications. -->                
+   <!-- This XSLT stylesheet test, illustrates an XPath 3.1 "for" 
+        expression evaluation, with XML namespace reference within
+        the XPath "for" expression's return expression. -->                
+
+   <xsl:output method="xml" indent="yes"/>
 
-   <xsl:output method="text"/>
-                                            
-   <xsl:template match="/company">                                                 
-      <xsl:variable name="officeDataInfo" select="let $x := office[@location = 'Boston'],
-                                                     $y := office[@location = 'Vienna']
-                                                     return concat('(a) Boston employee count : ', count($x/employee), 
-                                                                   ' (b) Vienna employee count : ', count($y/employee))"/>
-      <xsl:value-of select="$officeDataInfo"/>
+   <xsl:template match="/">
+      <result>
+        <xsl:value-of select="for $a in (1 to 5) return math:sin($a)"/>
+      </result>
    </xsl:template>
    
    <!--
diff --git a/tests/let_expr/test3.xsl b/tests/for_expr/test9.xsl
similarity index 54%
copy from tests/let_expr/test3.xsl
copy to tests/for_expr/test9.xsl
index fb97834d..7af010e2 100644
--- a/tests/let_expr/test3.xsl
+++ b/tests/for_expr/test9.xsl
@@ -1,24 +1,22 @@
 <?xml version="1.0"?>
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                xmlns:xs="http://www.w3.org/2001/XMLSchema"
+                xmlns:math="http://www.w3.org/2005/xpath-functions/math"
+                exclude-result-prefixes="xs math"
                 version="3.0">
                 
    <!-- Author: mukulg@apache.org -->
    
-   <!-- use with test1_a.xml -->
-   
-   <!-- An XSLT stylesheet test, for the XPath 3.1 "let" expression.
-        
-        This XSLT stylesheet, borrows an XPath "let" expression example 
-        from https://www.altova.com/, with slight modifications. -->                
+   <!-- This XSLT stylesheet test, illustrates an XPath 3.1 "for" 
+        expression evaluation, with XML namespace references within
+        the XPath "for" expression's return expression. -->                 
+
+   <xsl:output method="xml" indent="yes"/>
 
-   <xsl:output method="text"/>
-                                            
-   <xsl:template match="/company">                                                 
-      <xsl:variable name="officeDataInfo" select="let $x := office[@location = 'Boston'],
-                                                     $y := office[@location = 'Vienna']
-                                                     return concat('(a) Boston employee count : ', count($x/employee), 
-                                                                   ' (b) Vienna employee count : ', count($y/employee))"/>
-      <xsl:value-of select="$officeDataInfo"/>
+   <xsl:template match="/">
+      <result>
+        <xsl:value-of select="for $a in (1 to 5) return xs:integer(10) * math:sin($a)"/>
+      </result>
    </xsl:template>
    
    <!--
diff --git a/tests/if_expr/gold/test10.out b/tests/if_expr/gold/test10.out
new file mode 100644
index 00000000..4d2424cc
--- /dev/null
+++ b/tests/if_expr/gold/test10.out
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?><result xmlns:math="http://www.w3.org/2005/xpath-functions/math" inpUnit="radian">
+  <math:sin inp="0.3490658503988659">0.3420201433256687</math:sin>
+  <math:sin inp="0.5235987755982988">0.4999999999999999</math:sin>
+  <math:sin inp="0.7853981633974483">0.7071067811865475</math:sin>
+</result>
diff --git a/tests/if_expr/gold/test11.out b/tests/if_expr/gold/test11.out
new file mode 100644
index 00000000..babcf02c
--- /dev/null
+++ b/tests/if_expr/gold/test11.out
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?><result xmlns:math="http://www.w3.org/2005/xpath-functions/math" inpUnit="radian">
+  <math:sin inp="0.17453292519943295">0.1736481776669303</math:sin>
+  <math:sin inp="0.3490658503988659">0.3420201433256687</math:sin>
+  <math:sin inp="0.5235987755982988">0.4999999999999999</math:sin>
+  <math:sin inp="0.6981317007977318">0.6427876096865393</math:sin>
+  <math:sin inp="0.8726646259971648">0.766044443118978</math:sin>
+  <math:sin inp="1.0471975511965976">0.8660254037844386</math:sin>
+  <math:sin inp="1.2217304763960306">0.9396926207859083</math:sin>
+  <math:sin inp="1.3962634015954636">0.984807753012208</math:sin>
+</result>
diff --git a/tests/if_expr/gold/test9.out b/tests/if_expr/gold/test9.out
new file mode 100644
index 00000000..5e33125a
--- /dev/null
+++ b/tests/if_expr/gold/test9.out
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?><result xmlns:math="http://www.w3.org/2005/xpath-functions/math" inpUnit="degree">
+  <math:sin inp="20">0.3420201433256687</math:sin>
+  <math:sin inp="30">0.4999999999999999</math:sin>
+  <math:sin inp="45">0.7071067811865475</math:sin>
+  <math:sin inp="120">0.8660254037844387</math:sin>
+  <math:sin inp="180">0.0000000000000001</math:sin>
+</result>
diff --git a/tests/if_expr/test10.xsl b/tests/if_expr/test10.xsl
new file mode 100644
index 00000000..45bee9ba
--- /dev/null
+++ b/tests/if_expr/test10.xsl
@@ -0,0 +1,51 @@
+<?xml version="1.0"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                xmlns:xs="http://www.w3.org/2001/XMLSchema"
+                xmlns:math="http://www.w3.org/2005/xpath-functions/math"
+                exclude-result-prefixes="xs"
+                version="3.0">
+                
+   <!-- Author: mukulg@apache.org -->
+   
+   <!-- An XSLT stylesheet test, for the XPath 3.1 "if" expression. -->                
+
+   <xsl:output method="xml" indent="yes"/>
+   
+   <xsl:variable name="degToRadian" select="function($deg) { $deg * (math:pi() div 180) }"/>      
+      
+   <xsl:variable name="inpUnit" select="'radian'"/>
+   
+   <xsl:template match="/temp">
+      <xsl:variable name="inpSeq" select="for $a in val return $degToRadian($a)"/>
+      <result xmlns:math="http://www.w3.org/2005/xpath-functions/math" inpUnit="{$inpUnit}">
+        <xsl:for-each select="$inpSeq">
+           <xsl:variable name="inpVal" select="."/>
+           <xsl:variable name="inpValRadian" select="if ($inpUnit = 'degree') then 
+                                                              ($inpVal * (math:pi() div 180)) 
+                                                                              else $inpVal"/>
+           <math:sin inp="{$inpVal}">
+             <xsl:value-of select="let $a := xs:double($inpValRadian) return math:sin($a)"/>
+           </math:sin>
+        </xsl:for-each>
+      </result>
+   </xsl:template>
+   
+   <!--
+      * Licensed to the Apache Software Foundation (ASF) under one
+      * or more contributor license agreements. See the NOTICE file
+      * distributed with this work for additional information
+      * regarding copyright ownership. The ASF licenses this file
+      * to you under the Apache License, Version 2.0 (the  "License");
+      * you may not use this file except in compliance with the License.
+      * You may obtain a copy of the License at
+      *
+      *     http://www.apache.org/licenses/LICENSE-2.0
+      *
+      * Unless required by applicable law or agreed to in writing, software
+      * distributed under the License is distributed on an "AS IS" BASIS,
+      * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+      * See the License for the specific language governing permissions and
+      * limitations under the License.
+   -->
+
+</xsl:stylesheet>
\ No newline at end of file
diff --git a/tests/if_expr/test1_g.xml b/tests/if_expr/test1_g.xml
new file mode 100644
index 00000000..ad3bf47c
--- /dev/null
+++ b/tests/if_expr/test1_g.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0"?>
+<temp>
+  <val>10</val>
+  <val>20</val>
+  <val>30</val>
+  <val>40</val>
+  <val>50</val>
+  <val>60</val>
+  <val>70</val>
+  <val>80</val>
+</temp>
+ 
\ No newline at end of file
diff --git a/tests/let_expr/test3.xsl b/tests/if_expr/test8.xsl
similarity index 51%
copy from tests/let_expr/test3.xsl
copy to tests/if_expr/test8.xsl
index fb97834d..154da193 100644
--- a/tests/let_expr/test3.xsl
+++ b/tests/if_expr/test8.xsl
@@ -1,24 +1,32 @@
 <?xml version="1.0"?>
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                xmlns:xs="http://www.w3.org/2001/XMLSchema"
+                xmlns:math="http://www.w3.org/2005/xpath-functions/math"
+                exclude-result-prefixes="xs"
                 version="3.0">
                 
    <!-- Author: mukulg@apache.org -->
    
-   <!-- use with test1_a.xml -->
+   <!-- An XSLT stylesheet test, for the XPath 3.1 "if" expression. -->                
+
+   <xsl:output method="xml" indent="yes"/>      
+   
+   <xsl:variable name="inpSeq" select="(20, 30, 45, 120, 180)"/>
    
-   <!-- An XSLT stylesheet test, for the XPath 3.1 "let" expression.
-        
-        This XSLT stylesheet, borrows an XPath "let" expression example 
-        from https://www.altova.com/, with slight modifications. -->                
+   <xsl:variable name="inpUnit" select="'degree'"/>
 
-   <xsl:output method="text"/>
-                                            
-   <xsl:template match="/company">                                                 
-      <xsl:variable name="officeDataInfo" select="let $x := office[@location = 'Boston'],
-                                                     $y := office[@location = 'Vienna']
-                                                     return concat('(a) Boston employee count : ', count($x/employee), 
-                                                                   ' (b) Vienna employee count : ', count($y/employee))"/>
-      <xsl:value-of select="$officeDataInfo"/>
+   <xsl:template match="/">
+      <result xmlns:math="http://www.w3.org/2005/xpath-functions/math" inpUnit="{$inpUnit}">
+        <xsl:for-each select="$inpSeq">
+           <xsl:variable name="inpVal" select="."/>
+           <xsl:variable name="inpValRadian" select="if ($inpUnit = 'degree') then 
+                                                              ($inpVal * (math:pi() div 180)) 
+                                                                              else $inpVal"/>
+           <math:sin inp="{$inpVal}">
+             <xsl:value-of select="let $a := xs:double($inpValRadian) return math:sin($a)"/>
+           </math:sin>
+        </xsl:for-each>
+      </result>
    </xsl:template>
    
    <!--
diff --git a/tests/if_expr/test9.xsl b/tests/if_expr/test9.xsl
new file mode 100644
index 00000000..6ea6f973
--- /dev/null
+++ b/tests/if_expr/test9.xsl
@@ -0,0 +1,52 @@
+<?xml version="1.0"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                xmlns:xs="http://www.w3.org/2001/XMLSchema"
+                xmlns:math="http://www.w3.org/2005/xpath-functions/math"
+                exclude-result-prefixes="xs"
+                version="3.0">
+                
+   <!-- Author: mukulg@apache.org -->
+   
+   <!-- An XSLT stylesheet test, for the XPath 3.1 "if" expression. -->                
+
+   <xsl:output method="xml" indent="yes"/>
+   
+   <xsl:variable name="degToRadian" select="function($deg) { $deg * (math:pi() div 180) }"/>
+   
+   <xsl:variable name="inpSeq" select="($degToRadian(20), $degToRadian(30), $degToRadian(45))"/>
+      
+   <xsl:variable name="inpUnit" select="'radian'"/>
+   
+   <xsl:template match="/">      
+      <result xmlns:math="http://www.w3.org/2005/xpath-functions/math" inpUnit="{$inpUnit}">
+        <xsl:for-each select="$inpSeq">
+           <xsl:variable name="inpVal" select="."/>
+           <xsl:variable name="inpValRadian" select="if ($inpUnit = 'degree') then 
+                                                              ($inpVal * (math:pi() div 180)) 
+                                                                              else $inpVal"/>
+           <math:sin inp="{$inpVal}">
+             <xsl:value-of select="let $a := xs:double($inpValRadian) return math:sin($a)"/>
+           </math:sin>
+        </xsl:for-each>
+      </result>
+   </xsl:template>
+   
+   <!--
+      * Licensed to the Apache Software Foundation (ASF) under one
+      * or more contributor license agreements. See the NOTICE file
+      * distributed with this work for additional information
+      * regarding copyright ownership. The ASF licenses this file
+      * to you under the Apache License, Version 2.0 (the  "License");
+      * you may not use this file except in compliance with the License.
+      * You may obtain a copy of the License at
+      *
+      *     http://www.apache.org/licenses/LICENSE-2.0
+      *
+      * Unless required by applicable law or agreed to in writing, software
+      * distributed under the License is distributed on an "AS IS" BASIS,
+      * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+      * See the License for the specific language governing permissions and
+      * limitations under the License.
+   -->
+
+</xsl:stylesheet>
\ No newline at end of file
diff --git a/tests/let_expr/gold/test4.out b/tests/let_expr/gold/test4.out
new file mode 100644
index 00000000..4bc49888
--- /dev/null
+++ b/tests/let_expr/gold/test4.out
@@ -0,0 +1 @@
+<?xml version="1.0" encoding="UTF-8"?><result>-0.9589242746631385</result>
diff --git a/tests/let_expr/gold/test5.out b/tests/let_expr/gold/test5.out
new file mode 100644
index 00000000..122c4aa2
--- /dev/null
+++ b/tests/let_expr/gold/test5.out
@@ -0,0 +1 @@
+<?xml version="1.0" encoding="UTF-8"?><result>-9.589242746631385</result>
diff --git a/tests/let_expr/gold/test6.out b/tests/let_expr/gold/test6.out
new file mode 100644
index 00000000..417a7fbe
--- /dev/null
+++ b/tests/let_expr/gold/test6.out
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?><result xmlns:math="http://www.w3.org/2005/xpath-functions/math">
+  <math:sin inp="1">0.8414709848078965</math:sin>
+  <math:sin inp="2">0.9092974268256817</math:sin>
+  <math:sin inp="3">0.1411200080598672</math:sin>
+  <math:sin inp="4">-0.7568024953079282</math:sin>
+  <math:sin inp="5">-0.9589242746631385</math:sin>
+  <math:sin inp="6">-0.2794154981989259</math:sin>
+  <math:sin inp="7">0.6569865987187891</math:sin>
+  <math:sin inp="8">0.9893582466233818</math:sin>
+  <math:sin inp="9">0.4121184852417566</math:sin>
+  <math:sin inp="10">-0.5440211108893698</math:sin>
+</result>
diff --git a/tests/let_expr/gold/test7.out b/tests/let_expr/gold/test7.out
new file mode 100644
index 00000000..78269713
--- /dev/null
+++ b/tests/let_expr/gold/test7.out
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?><result xmlns:math="http://www.w3.org/2005/xpath-functions/math">
+  <math:sin inp="1">0.8414709848078965</math:sin>
+  <math:sin inp="2">0.9092974268256817</math:sin>
+  <math:sin inp="3">0.1411200080598672</math:sin>
+</result>
diff --git a/tests/let_expr/gold/test8.out b/tests/let_expr/gold/test8.out
new file mode 100644
index 00000000..5e33125a
--- /dev/null
+++ b/tests/let_expr/gold/test8.out
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?><result xmlns:math="http://www.w3.org/2005/xpath-functions/math" inpUnit="degree">
+  <math:sin inp="20">0.3420201433256687</math:sin>
+  <math:sin inp="30">0.4999999999999999</math:sin>
+  <math:sin inp="45">0.7071067811865475</math:sin>
+  <math:sin inp="120">0.8660254037844387</math:sin>
+  <math:sin inp="180">0.0000000000000001</math:sin>
+</result>
diff --git a/tests/let_expr/test1_b.xml b/tests/let_expr/test1_b.xml
new file mode 100644
index 00000000..1f862478
--- /dev/null
+++ b/tests/let_expr/test1_b.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0"?>
+<temp>
+  <a>1</a>
+  <b>10</b>
+</temp>
+ 
\ No newline at end of file
diff --git a/tests/let_expr/test3.xsl b/tests/let_expr/test3.xsl
index fb97834d..9d01c5f2 100644
--- a/tests/let_expr/test3.xsl
+++ b/tests/let_expr/test3.xsl
@@ -15,9 +15,9 @@
                                             
    <xsl:template match="/company">                                                 
       <xsl:variable name="officeDataInfo" select="let $x := office[@location = 'Boston'],
-                                                     $y := office[@location = 'Vienna']
-                                                     return concat('(a) Boston employee count : ', count($x/employee), 
-                                                                   ' (b) Vienna employee count : ', count($y/employee))"/>
+                                                      $y := office[@location = 'Vienna']
+                                                                return concat('(a) Boston employee count : ', count($x/employee), 
+                                                                          ' (b) Vienna employee count : ', count($y/employee))"/>
       <xsl:value-of select="$officeDataInfo"/>
    </xsl:template>
    
diff --git a/tests/let_expr/test3.xsl b/tests/let_expr/test4.xsl
similarity index 54%
copy from tests/let_expr/test3.xsl
copy to tests/let_expr/test4.xsl
index fb97834d..37e425af 100644
--- a/tests/let_expr/test3.xsl
+++ b/tests/let_expr/test4.xsl
@@ -1,24 +1,21 @@
 <?xml version="1.0"?>
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                xmlns:math="http://www.w3.org/2005/xpath-functions/math"
+                exclude-result-prefixes="math"
                 version="3.0">
                 
    <!-- Author: mukulg@apache.org -->
    
-   <!-- use with test1_a.xml -->
-   
-   <!-- An XSLT stylesheet test, for the XPath 3.1 "let" expression.
-        
-        This XSLT stylesheet, borrows an XPath "let" expression example 
-        from https://www.altova.com/, with slight modifications. -->                
+   <!-- This XSLT stylesheet test, illustrates an XPath 3.1 "let" 
+        expression evaluation, with XML namespace reference within
+        the XPath "let" expression's return expression. -->                 
+
+   <xsl:output method="xml" indent="yes"/>
 
-   <xsl:output method="text"/>
-                                            
-   <xsl:template match="/company">                                                 
-      <xsl:variable name="officeDataInfo" select="let $x := office[@location = 'Boston'],
-                                                     $y := office[@location = 'Vienna']
-                                                     return concat('(a) Boston employee count : ', count($x/employee), 
-                                                                   ' (b) Vienna employee count : ', count($y/employee))"/>
-      <xsl:value-of select="$officeDataInfo"/>
+   <xsl:template match="/">
+      <result>
+         <xsl:value-of select="let $a := 5 return math:sin($a)"/>
+      </result>
    </xsl:template>
    
    <!--
diff --git a/tests/let_expr/test3.xsl b/tests/let_expr/test5.xsl
similarity index 54%
copy from tests/let_expr/test3.xsl
copy to tests/let_expr/test5.xsl
index fb97834d..9dabf280 100644
--- a/tests/let_expr/test3.xsl
+++ b/tests/let_expr/test5.xsl
@@ -1,24 +1,22 @@
 <?xml version="1.0"?>
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                xmlns:xs="http://www.w3.org/2001/XMLSchema"
+                xmlns:math="http://www.w3.org/2005/xpath-functions/math"
+                exclude-result-prefixes="xs math"
                 version="3.0">
                 
    <!-- Author: mukulg@apache.org -->
    
-   <!-- use with test1_a.xml -->
-   
-   <!-- An XSLT stylesheet test, for the XPath 3.1 "let" expression.
-        
-        This XSLT stylesheet, borrows an XPath "let" expression example 
-        from https://www.altova.com/, with slight modifications. -->                
+   <!-- This XSLT stylesheet test, illustrates an XPath 3.1 "let" 
+        expression evaluation, with XML namespace references within
+        the XPath "let" expression. -->                 
+
+   <xsl:output method="xml" indent="yes"/>
 
-   <xsl:output method="text"/>
-                                            
-   <xsl:template match="/company">                                                 
-      <xsl:variable name="officeDataInfo" select="let $x := office[@location = 'Boston'],
-                                                     $y := office[@location = 'Vienna']
-                                                     return concat('(a) Boston employee count : ', count($x/employee), 
-                                                                   ' (b) Vienna employee count : ', count($y/employee))"/>
-      <xsl:value-of select="$officeDataInfo"/>
+   <xsl:template match="/">
+      <result>
+        <xsl:value-of select="let $a := xs:double(5) return xs:integer(10) * math:sin($a)"/>
+      </result>
    </xsl:template>
    
    <!--
diff --git a/tests/let_expr/test3.xsl b/tests/let_expr/test6.xsl
similarity index 54%
copy from tests/let_expr/test3.xsl
copy to tests/let_expr/test6.xsl
index fb97834d..a7a9bbb4 100644
--- a/tests/let_expr/test3.xsl
+++ b/tests/let_expr/test6.xsl
@@ -1,24 +1,29 @@
 <?xml version="1.0"?>
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                xmlns:xs="http://www.w3.org/2001/XMLSchema"
+                xmlns:math="http://www.w3.org/2005/xpath-functions/math"
+                exclude-result-prefixes="xs"
                 version="3.0">
                 
    <!-- Author: mukulg@apache.org -->
    
-   <!-- use with test1_a.xml -->
+   <!-- use with test1_b.xml -->
    
-   <!-- An XSLT stylesheet test, for the XPath 3.1 "let" expression.
-        
-        This XSLT stylesheet, borrows an XPath "let" expression example 
-        from https://www.altova.com/, with slight modifications. -->                
+   <!-- This XSLT stylesheet test, illustrates an XPath 3.1 "let" 
+        expression evaluation, with XML namespace references within
+        the XPath "let" expression. -->                  
 
-   <xsl:output method="text"/>
-                                            
-   <xsl:template match="/company">                                                 
-      <xsl:variable name="officeDataInfo" select="let $x := office[@location = 'Boston'],
-                                                     $y := office[@location = 'Vienna']
-                                                     return concat('(a) Boston employee count : ', count($x/employee), 
-                                                                   ' (b) Vienna employee count : ', count($y/employee))"/>
-      <xsl:value-of select="$officeDataInfo"/>
+   <xsl:output method="xml" indent="yes"/>
+
+   <xsl:template match="/temp">
+      <result xmlns:math="http://www.w3.org/2005/xpath-functions/math">
+        <xsl:for-each select="a to b">
+           <xsl:variable name="inpVal" select="."/>
+           <math:sin inp="{$inpVal}">
+             <xsl:value-of select="let $a := xs:double($inpVal) return math:sin($a)"/>
+           </math:sin>
+        </xsl:for-each>
+      </result>
    </xsl:template>
    
    <!--
diff --git a/tests/let_expr/test3.xsl b/tests/let_expr/test7.xsl
similarity index 57%
copy from tests/let_expr/test3.xsl
copy to tests/let_expr/test7.xsl
index fb97834d..df8a861d 100644
--- a/tests/let_expr/test3.xsl
+++ b/tests/let_expr/test7.xsl
@@ -1,24 +1,25 @@
 <?xml version="1.0"?>
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                xmlns:xs="http://www.w3.org/2001/XMLSchema"
+                xmlns:math="http://www.w3.org/2005/xpath-functions/math"
+                exclude-result-prefixes="xs"
                 version="3.0">
                 
    <!-- Author: mukulg@apache.org -->
    
-   <!-- use with test1_a.xml -->
-   
-   <!-- An XSLT stylesheet test, for the XPath 3.1 "let" expression.
-        
-        This XSLT stylesheet, borrows an XPath "let" expression example 
-        from https://www.altova.com/, with slight modifications. -->                
+   <!-- An XSLT stylesheet test, for the XPath 3.1 "let" expression. -->                
+
+   <xsl:output method="xml" indent="yes"/>
 
-   <xsl:output method="text"/>
-                                            
-   <xsl:template match="/company">                                                 
-      <xsl:variable name="officeDataInfo" select="let $x := office[@location = 'Boston'],
-                                                     $y := office[@location = 'Vienna']
-                                                     return concat('(a) Boston employee count : ', count($x/employee), 
-                                                                   ' (b) Vienna employee count : ', count($y/employee))"/>
-      <xsl:value-of select="$officeDataInfo"/>
+   <xsl:template match="/">
+      <result xmlns:math="http://www.w3.org/2005/xpath-functions/math">
+        <xsl:for-each select="(1, 2, 3)">
+           <xsl:variable name="inpVal" select="."/>
+           <math:sin inp="{$inpVal}">
+             <xsl:value-of select="let $a := xs:double($inpVal) return math:sin($a)"/>
+           </math:sin>
+        </xsl:for-each>
+      </result>
    </xsl:template>
    
    <!--
diff --git a/tests/let_expr/test3.xsl b/tests/let_expr/test8.xsl
similarity index 57%
copy from tests/let_expr/test3.xsl
copy to tests/let_expr/test8.xsl
index fb97834d..2995d9a7 100644
--- a/tests/let_expr/test3.xsl
+++ b/tests/let_expr/test8.xsl
@@ -1,24 +1,26 @@
 <?xml version="1.0"?>
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                xmlns:xs="http://www.w3.org/2001/XMLSchema"
+                xmlns:math="http://www.w3.org/2005/xpath-functions/math"
+                exclude-result-prefixes="xs"
                 version="3.0">
                 
    <!-- Author: mukulg@apache.org -->
    
-   <!-- use with test1_a.xml -->
-   
-   <!-- An XSLT stylesheet test, for the XPath 3.1 "let" expression.
-        
-        This XSLT stylesheet, borrows an XPath "let" expression example 
-        from https://www.altova.com/, with slight modifications. -->                
+   <!-- An XSLT stylesheet test, for the XPath 3.1 "let" expression. -->                
+
+   <xsl:output method="xml" indent="yes"/>
 
-   <xsl:output method="text"/>
-                                            
-   <xsl:template match="/company">                                                 
-      <xsl:variable name="officeDataInfo" select="let $x := office[@location = 'Boston'],
-                                                     $y := office[@location = 'Vienna']
-                                                     return concat('(a) Boston employee count : ', count($x/employee), 
-                                                                   ' (b) Vienna employee count : ', count($y/employee))"/>
-      <xsl:value-of select="$officeDataInfo"/>
+   <xsl:template match="/">
+      <result xmlns:math="http://www.w3.org/2005/xpath-functions/math" inpUnit="degree">
+         <xsl:for-each select="(20, 30, 45, 120, 180)">
+            <xsl:variable name="inpValDegree" select="."/>
+            <xsl:variable name="inpValRadian" select="$inpValDegree * (math:pi() div 180)"/>
+            <math:sin inp="{$inpValDegree}">
+               <xsl:value-of select="let $a := xs:double($inpValRadian) return math:sin($a)"/>
+            </math:sin>
+         </xsl:for-each>
+      </result>
    </xsl:template>
    
    <!--
diff --git a/tests/org/apache/xalan/util/XslTransformTestsUtil.java b/tests/org/apache/xalan/util/XslTransformTestsUtil.java
index 41ee006f..3d77af6c 100644
--- a/tests/org/apache/xalan/util/XslTransformTestsUtil.java
+++ b/tests/org/apache/xalan/util/XslTransformTestsUtil.java
@@ -61,6 +61,7 @@ public class XslTransformTestsUtil {
         System.setProperty(XSLConstants.XSLT_TRANSFORMER_FACTORY_KEY, XSLConstants.XSLT_TRANSFORMER_FACTORY_VALUE);                
         
         xmlDocumentBuilderFactory = DocumentBuilderFactory.newInstance();
+        xmlDocumentBuilderFactory.setNamespaceAware(true);
         
         try {
             xmlDocumentBuilder = xmlDocumentBuilderFactory.newDocumentBuilder();
diff --git a/tests/org/apache/xalan/xpath3/ForExprTests.java b/tests/org/apache/xalan/xpath3/ForExprTests.java
index b176ee64..221c20b1 100644
--- a/tests/org/apache/xalan/xpath3/ForExprTests.java
+++ b/tests/org/apache/xalan/xpath3/ForExprTests.java
@@ -116,5 +116,35 @@ public class ForExprTests extends XslTransformTestsUtil {
         
         runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
     }
+    
+    @Test
+    public void xslForExprTest8() {
+        String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test8.xsl"; 
+        String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test8.xsl";
+        
+        String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test8.out";                
+        
+        runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+    }
+    
+    @Test
+    public void xslForExprTest9() {
+        String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test9.xsl"; 
+        String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test9.xsl";
+        
+        String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test9.out";                
+        
+        runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+    }
+    
+    @Test
+    public void xslForExprTest10() {
+        String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test10.xsl"; 
+        String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test10.xsl";
+        
+        String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test10.out";                
+        
+        runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+    }
 
 }
diff --git a/tests/org/apache/xalan/xpath3/IfExprTests.java b/tests/org/apache/xalan/xpath3/IfExprTests.java
index e97a7a06..658cbb09 100644
--- a/tests/org/apache/xalan/xpath3/IfExprTests.java
+++ b/tests/org/apache/xalan/xpath3/IfExprTests.java
@@ -126,5 +126,35 @@ public class IfExprTests extends XslTransformTestsUtil {
         
         runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
     }
+    
+    @Test
+    public void xslIfExprTest9() {
+        String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test8.xsl"; 
+        String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test8.xsl";
+        
+        String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test9.out";                
+        
+        runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+    }
+    
+    @Test
+    public void xslIfExprTest10() {
+        String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test9.xsl"; 
+        String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test9.xsl";
+        
+        String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test10.out";                
+        
+        runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+    }
+    
+    @Test
+    public void xslIfExprTest11() {
+        String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test1_g.xml"; 
+        String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test10.xsl";
+        
+        String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test11.out";                
+        
+        runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+    }
 
 }
diff --git a/tests/org/apache/xalan/xpath3/LetExprTests.java b/tests/org/apache/xalan/xpath3/LetExprTests.java
index 644e38c1..48d62e12 100644
--- a/tests/org/apache/xalan/xpath3/LetExprTests.java
+++ b/tests/org/apache/xalan/xpath3/LetExprTests.java
@@ -76,5 +76,55 @@ public class LetExprTests extends XslTransformTestsUtil {
         
         runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
     }
+    
+    @Test
+    public void xslLetExprTest4() {
+        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 xslLetExprTest5() {
+        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 xslLetExprTest6() {
+        String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test1_b.xml"; 
+        String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test6.xsl";
+        
+        String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test6.out";                
+        
+        runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+    }
+    
+    @Test
+    public void xslLetExprTest7() {
+        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);
+    }
+    
+    @Test
+    public void xslLetExprTest8() {
+        String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test8.xsl"; 
+        String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test8.xsl";
+        
+        String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test8.out";                
+        
+        runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+    }
 
 }
diff --git a/tests/org/apache/xalan/xpath3/QuantifiedExprTests.java b/tests/org/apache/xalan/xpath3/QuantifiedExprTests.java
index 9ccecf55..10dc49b6 100644
--- a/tests/org/apache/xalan/xpath3/QuantifiedExprTests.java
+++ b/tests/org/apache/xalan/xpath3/QuantifiedExprTests.java
@@ -151,5 +151,15 @@ public class QuantifiedExprTests extends XslTransformTestsUtil {
         
         runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
     }
+    
+    @Test
+    public void xslQuantifiedExprTest11() {
+        String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test1_g.xml"; 
+        String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test10.xsl";
+        
+        String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test11.out";                
+        
+        runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+    }
 
 }
diff --git a/tests/quantified_expr/gold/test11.out b/tests/quantified_expr/gold/test11.out
new file mode 100644
index 00000000..05e5bb77
--- /dev/null
+++ b/tests/quantified_expr/gold/test11.out
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?><result>
+  <one>true</one>
+  <two>false</two>
+</result>
diff --git a/tests/let_expr/test3.xsl b/tests/quantified_expr/test10.xsl
similarity index 54%
copy from tests/let_expr/test3.xsl
copy to tests/quantified_expr/test10.xsl
index fb97834d..1a196ee5 100644
--- a/tests/let_expr/test3.xsl
+++ b/tests/quantified_expr/test10.xsl
@@ -1,24 +1,27 @@
 <?xml version="1.0"?>
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                xmlns:xs="http://www.w3.org/2001/XMLSchema"
+                xmlns:ns0="http://xalan.apache.org/xalan-j"
+                exclude-result-prefixes="xs ns0"
                 version="3.0">
                 
    <!-- Author: mukulg@apache.org -->
    
-   <!-- use with test1_a.xml -->
+   <!-- use with test1_g.xml -->
    
-   <!-- An XSLT stylesheet test, for the XPath 3.1 "let" expression.
-        
-        This XSLT stylesheet, borrows an XPath "let" expression example 
-        from https://www.altova.com/, with slight modifications. -->                
+   <!-- An XSLT stylesheet test case, to test the XPath 3.1 quantified 
+        expressions 'some' and 'every'. This stylesheet example, tests
+        using XML namespace references within the XPath quantified
+        expressions.
+   -->                
 
-   <xsl:output method="text"/>
-                                            
-   <xsl:template match="/company">                                                 
-      <xsl:variable name="officeDataInfo" select="let $x := office[@location = 'Boston'],
-                                                     $y := office[@location = 'Vienna']
-                                                     return concat('(a) Boston employee count : ', count($x/employee), 
-                                                                   ' (b) Vienna employee count : ', count($y/employee))"/>
-      <xsl:value-of select="$officeDataInfo"/>
+   <xsl:output method="xml" indent="yes"/>
+   
+   <xsl:template match="/ns0:temp">
+      <result>
+        <one><xsl:value-of select="some $a in ns0:val satisfies xs:integer($a) lt xs:integer(50)"/></one>
+        <two><xsl:value-of select="every $a in ns0:val satisfies xs:integer($a) lt xs:integer(50)"/></two>
+      </result>
    </xsl:template>
    
    <!--
diff --git a/tests/quantified_expr/test1_g.xml b/tests/quantified_expr/test1_g.xml
new file mode 100644
index 00000000..693c2fd2
--- /dev/null
+++ b/tests/quantified_expr/test1_g.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0"?>
+<temp xmlns="http://xalan.apache.org/xalan-j">
+  <val>10</val>
+  <val>20</val>
+  <val>30</val>
+  <val>40</val>
+  <val>50</val>
+  <val>60</val>
+  <val>70</val>
+  <val>80</val>
+</temp>
+ 
\ No newline at end of file


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