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/06/03 08:51:08 UTC

[xalan-java] branch xalan-j_xslt3.0 updated: committing little bit more xslt 3.0 and xpath 3.1 implementation codebase. also committing, few working related test cases.

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 bbedbdfb committing little bit more xslt 3.0 and xpath 3.1 implementation codebase. also committing, few working related test cases.
bbedbdfb is described below

commit bbedbdfb1c2fd4a520ff3d39059f15771884a7d0
Author: Mukul Gandhi <ga...@gmail.com>
AuthorDate: Sat Jun 3 14:20:29 2023 +0530

    committing little bit more xslt 3.0 and xpath 3.1 implementation codebase. also committing, few working related test cases.
---
 src/org/apache/xalan/templates/ElemValueOf.java    |  41 ++++-
 src/org/apache/xalan/templates/ElemVariable.java   |  69 ++++++++-
 .../xalan/templates/XSConstructorFunctionUtil.java |  97 ++++++++++++
 src/org/apache/xpath/compiler/Keywords.java        |  10 +-
 src/org/apache/xpath/objects/XNumber.java          |  10 +-
 src/org/apache/xpath/objects/XObject.java          |  10 +-
 src/org/apache/xpath/operations/Minus.java         |  29 +++-
 src/org/apache/xpath/operations/Plus.java          |  24 ++-
 src/org/apache/xpath/res/XPATHErrorResources.java  |  14 +-
 .../apache/xpath/xs/types/XPath3DecimalFormat.java | 130 ++++++++++++++++
 src/org/apache/xpath/xs/types/XSAnyAtomicType.java |  20 ++-
 src/org/apache/xpath/xs/types/XSAnyType.java       |  11 +-
 src/org/apache/xpath/xs/types/XSBoolean.java       | 116 ++++++++++++++
 src/org/apache/xpath/xs/types/XSCtrType.java       |  21 ++-
 src/org/apache/xpath/xs/types/XSDecimal.java       | 157 +++++++++++++++++++
 src/org/apache/xpath/xs/types/XSDouble.java        | 170 +++++++++++++++++++++
 src/org/apache/xpath/xs/types/XSFloat.java         | 153 +++++++++++++++++++
 .../xpath/xs/types/{XSCtrType.java => XSInt.java}  |  55 ++++---
 src/org/apache/xpath/xs/types/XSInteger.java       | 114 ++++++++++++++
 src/org/apache/xpath/xs/types/XSLong.java          |  64 ++++++++
 src/org/apache/xpath/xs/types/XSNumericType.java   |  53 +++++++
 tests/fn_abs/test1.xsl                             |  10 +-
 .../xalan/xpath3/XsConstructorFunctions.java       | 111 ++++++++++++++
 tests/org/apache/xalan/xslt3/AllXsl3Tests.java     |  11 +-
 tests/xs_constructor_functions/gold/test1.out      |  11 ++
 tests/xs_constructor_functions/gold/test2.out      |  10 ++
 tests/xs_constructor_functions/gold/test3.out      |   4 +
 tests/xs_constructor_functions/gold/test4.out      |   6 +
 tests/xs_constructor_functions/gold/test5.out      |   7 +
 tests/xs_constructor_functions/gold/test6.out      |   5 +
 .../{fn_abs => xs_constructor_functions}/test1.xsl |  46 +++---
 tests/xs_constructor_functions/test1_a.xml         |   7 +
 .../test2.xsl}                                     |  45 +++---
 .../test3.xsl}                                     |  32 +---
 .../test4.xsl}                                     |  35 ++---
 .../test5.xsl}                                     |  36 ++---
 .../test6.xsl}                                     |  40 ++---
 37 files changed, 1552 insertions(+), 232 deletions(-)

diff --git a/src/org/apache/xalan/templates/ElemValueOf.java b/src/org/apache/xalan/templates/ElemValueOf.java
index 9fcd1242..66592d83 100644
--- a/src/org/apache/xalan/templates/ElemValueOf.java
+++ b/src/org/apache/xalan/templates/ElemValueOf.java
@@ -15,9 +15,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-/*
- * $Id$
- */
 package org.apache.xalan.templates;
 
 import javax.xml.transform.TransformerException;
@@ -29,9 +26,11 @@ import org.apache.xml.serializer.SerializationHandler;
 import org.apache.xpath.Expression;
 import org.apache.xpath.XPath;
 import org.apache.xpath.XPathContext;
+import org.apache.xpath.functions.FuncExtFunction;
 import org.apache.xpath.functions.Function;
 import org.apache.xpath.objects.XObject;
 import org.apache.xpath.objects.XString;
+import org.apache.xpath.operations.Operation;
 import org.apache.xpath.operations.Variable;
 import org.apache.xpath.xs.types.XSAnyType;
 import org.w3c.dom.DOMException;
@@ -281,8 +280,21 @@ public class ElemValueOf extends ElemTemplateElement {
               if (m_isDot && xpath3ContextItem != null) {
                   xpath3ContextItem.dispatchCharactersEvents(rth);   
               }
-              else {                  
-                  if (expr instanceof Function) {
+              else {
+                  if (expr instanceof FuncExtFunction) {                      
+                      XObject evalResult = XSConstructorFunctionUtil.processFuncExtFunctionOrXPathOpn(xctxt, expr);
+                      String strValue = null;
+                      
+                      if (evalResult instanceof XSAnyType) {
+                          strValue = ((XSAnyType)evalResult).stringValue();    
+                      }
+                      else {
+                          strValue = evalResult.str();  
+                      }
+
+                      (new XString(strValue)).dispatchCharactersEvents(rth);
+                  }
+                  else if (expr instanceof Function) {
                       XObject evalResult = ((Function)expr).execute(xctxt);
                       String strValue = null;
                       if (evalResult instanceof XSAnyType) {
@@ -304,6 +316,23 @@ public class ElemValueOf extends ElemTemplateElement {
                       }
                       (new XString(strValue)).dispatchCharactersEvents(rth);
                   }
+                  else if (expr instanceof Operation) {
+                     Operation opn = (Operation)expr;
+                     XObject leftOperand = XSConstructorFunctionUtil.processFuncExtFunctionOrXPathOpn(
+                                                                                                xctxt, opn.getLeftOperand());
+                     XObject rightOperand = XSConstructorFunctionUtil.processFuncExtFunctionOrXPathOpn(
+                                                                                                xctxt, opn.getRightOperand());
+                     XObject evalResult = opn.operate(leftOperand, rightOperand);
+                     
+                     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);
                   }
@@ -323,7 +352,7 @@ public class ElemValueOf extends ElemTemplateElement {
     }
     catch (SAXException se)
     {
-      throw new TransformerException(se);
+        throw new TransformerException(se);
     }
     catch (RuntimeException re) {
     	TransformerException te = new TransformerException(re);
diff --git a/src/org/apache/xalan/templates/ElemVariable.java b/src/org/apache/xalan/templates/ElemVariable.java
index bedb5fa5..8b14015f 100644
--- a/src/org/apache/xalan/templates/ElemVariable.java
+++ b/src/org/apache/xalan/templates/ElemVariable.java
@@ -15,9 +15,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-/*
- * $Id$
- */
 package org.apache.xalan.templates;
 
 import javax.xml.transform.TransformerException;
@@ -28,6 +25,7 @@ import org.apache.xml.utils.QName;
 import org.apache.xpath.Expression;
 import org.apache.xpath.XPath;
 import org.apache.xpath.XPathContext;
+import org.apache.xpath.functions.FuncExtFunction;
 import org.apache.xpath.functions.Function;
 import org.apache.xpath.objects.ResultSequence;
 import org.apache.xpath.objects.XNodeSetForDOM;
@@ -35,8 +33,10 @@ import org.apache.xpath.objects.XObject;
 import org.apache.xpath.objects.XRTreeFrag;
 import org.apache.xpath.objects.XRTreeFragSelectWrapper;
 import org.apache.xpath.objects.XString;
+import org.apache.xpath.operations.Operation;
 import org.apache.xpath.xs.types.XSAnyType;
 import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
 
 /**
  * Implementation of XSLT 3.0 xsl:variable element.
@@ -275,8 +275,8 @@ public class ElemVariable extends ElemTemplateElement
    *
    * @throws TransformerException
    */
-  public XObject getValue(TransformerImpl transformer, int sourceNode)
-          throws TransformerException
+  public XObject getValue(TransformerImpl transformer, int sourceNode) 
+                                                                 throws TransformerException
   {
 
     XObject var;
@@ -290,14 +290,29 @@ public class ElemVariable extends ElemTemplateElement
     try {        
       if (m_selectPattern != null) {          
         Expression selectExpression = m_selectPattern.getExpression();
-        if (selectExpression instanceof Function) {
+        if (selectExpression instanceof FuncExtFunction) {
+            XObject evalResult = XSConstructorFunctionUtil.processFuncExtFunctionOrXPathOpn(xctxt, 
+                                                                                        selectExpression);
+            return evalResult;
+        }
+        else if (selectExpression instanceof Function) {
             XObject evalResult = ((Function)selectExpression).execute(xctxt);            
             if ((evalResult instanceof ResultSequence) || 
-                                            (evalResult instanceof XSAnyType)) {
+                                                (evalResult instanceof XSAnyType)) {
                 var = evalResult;
                 return var; 
             }
-        } 
+        }
+        else if (selectExpression instanceof Operation) {
+            Operation opn = (Operation)selectExpression;
+            XObject leftOperand = XSConstructorFunctionUtil.processFuncExtFunctionOrXPathOpn(
+                                                                                         xctxt, opn.getLeftOperand());
+            XObject rightOperand = XSConstructorFunctionUtil.processFuncExtFunctionOrXPathOpn(
+                                                                                         xctxt, opn.getRightOperand());
+            XObject evalResult = opn.operate(leftOperand, rightOperand);
+            
+            return evalResult;
+        }
           
         var = m_selectPattern.execute(xctxt, sourceNode, this);
 
@@ -337,6 +352,9 @@ public class ElemVariable extends ElemTemplateElement
 		var = new XNodeSetForDOM(nodeList, xctxt); 
       }
     }
+    catch (SAXException se) {
+        throw new TransformerException(se);
+    }
     finally {      
        xctxt.popCurrentNode();
     }
@@ -556,5 +574,40 @@ public class ElemVariable extends ElemTemplateElement
     }
     return super.appendChild(elem);
   }
+  
+  /*private XObject processFuncExtFunction(XPathContext xctxt, Expression expr)
+                                                                  throws TransformerException, SAXException {    
+      XObject evalResult = null;
+
+      FuncExtFunction funcExtFunction = (FuncExtFunction)expr;
+
+      if (XMLConstants.W3C_XML_SCHEMA_NS_URI.equals(funcExtFunction.
+              getNamespace())) {                            
+          if ((Keywords.FUNC_XS_DECIMAL).equals(funcExtFunction.getFunctionName())) {                              
+              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()));
+              }
+
+              ResultSequence rSeq = (new XSDecimal()).constructor(argSequence);
+              evalResult = rSeq.item(0);              
+          }
+          else if ((Keywords.FUNC_BOOLEAN_STRING).equals(funcExtFunction.getFunctionName())) {                              
+              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");
+                  argSequence.add(new XSBoolean(boolVal));
+              }
+
+              ResultSequence rSeq = (new XSBoolean()).constructor(argSequence);
+              evalResult = rSeq.item(0);              
+          }
+      }
+
+      return evalResult;
+   }  */
 
 }
diff --git a/src/org/apache/xalan/templates/XSConstructorFunctionUtil.java b/src/org/apache/xalan/templates/XSConstructorFunctionUtil.java
new file mode 100644
index 00000000..0dfedda3
--- /dev/null
+++ b/src/org/apache/xalan/templates/XSConstructorFunctionUtil.java
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.xalan.templates;
+
+import javax.xml.XMLConstants;
+import javax.xml.transform.TransformerException;
+
+import org.apache.xpath.Expression;
+import org.apache.xpath.XPathContext;
+import org.apache.xpath.compiler.Keywords;
+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.XSBoolean;
+import org.apache.xpath.xs.types.XSDecimal;
+import org.xml.sax.SAXException;
+
+/**
+ * An utility class, to support evaluations of XPath 3.1 constructor 
+ * functions, and few other XPath expression evaluations.
+ * 
+ * @author Mukul Gandhi <mu...@apache.org>
+ * 
+ * @xsl.usage advanced
+ */
+public class XSConstructorFunctionUtil {
+    
+    /*
+     * Process an XPath expression of the type FuncExtFunction, XPath operation, 
+     * and also few default XPath expression processing. 
+     */
+    public static XObject processFuncExtFunctionOrXPathOpn(XPathContext xctxt, Expression expr)
+                                                                    throws TransformerException, SAXException {        
+        XObject evalResult = null;
+
+        if (expr instanceof FuncExtFunction) {
+            FuncExtFunction funcExtFunction = (FuncExtFunction)expr;
+            if (XMLConstants.W3C_XML_SCHEMA_NS_URI.equals(funcExtFunction.getNamespace())) {
+                // evaluate XPath 3.1 constructor function calls, corresponding to XML Schema 
+                // built-in types.
+                if ((Keywords.FUNC_XS_DECIMAL).equals(funcExtFunction.getFunctionName())) {                              
+                    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()));
+                    }
+
+                    ResultSequence rSeq = (new XSDecimal()).constructor(argSequence);
+                    evalResult = rSeq.item(0);              
+                }
+                else if ((Keywords.FUNC_BOOLEAN_STRING).equals(funcExtFunction.getFunctionName())) {                              
+                    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");
+                        argSequence.add(new XSBoolean(boolVal));
+                    }
+
+                    ResultSequence rSeq = (new XSBoolean()).constructor(argSequence);
+                    evalResult = rSeq.item(0);              
+                }
+            }
+        }
+        else if (expr instanceof Operation) {
+            // we need to call this method recursively, for the possibility of more than one
+            // XPath expression evaluation operator present within an XPath expression.
+            // for e.g, a + b - c.
+            Operation opn = (Operation)expr;
+            XObject leftOperand = processFuncExtFunctionOrXPathOpn(xctxt, opn.getLeftOperand());
+            XObject rightOperand = processFuncExtFunctionOrXPathOpn(xctxt, opn.getRightOperand());
+            evalResult = opn.operate(leftOperand, rightOperand);
+        }
+        else {
+            evalResult = expr.execute(xctxt);   
+        }
+
+        return evalResult;
+        
+    }
+
+}
diff --git a/src/org/apache/xpath/compiler/Keywords.java b/src/org/apache/xpath/compiler/Keywords.java
index ebc1c68d..ea7e1f4c 100644
--- a/src/org/apache/xpath/compiler/Keywords.java
+++ b/src/org/apache/xpath/compiler/Keywords.java
@@ -141,7 +141,10 @@ public class Keywords
   /** false function string. */
   public static final String FUNC_FALSE_STRING = "false";
 
-  /** boolean function string. */
+  /**
+   * boolean function string. we use this same configuration, 
+   * for XML Schema data type xs:boolean as well.
+   */
   public static final String FUNC_BOOLEAN_STRING = "boolean";
 
   /** lang function string. */
@@ -257,6 +260,11 @@ public class Keywords
 
   /** current function string (Proprietary). */
   public static final String FUNC_DOCLOCATION_STRING = "document-location";
+  
+  //XML Schema built-in types constructor functions, configurations
+  
+  /** xs:decimal data type string. */
+  public static final String FUNC_XS_DECIMAL = "decimal";
 
   static
   {
diff --git a/src/org/apache/xpath/objects/XNumber.java b/src/org/apache/xpath/objects/XNumber.java
index 5b053b12..74e351a0 100644
--- a/src/org/apache/xpath/objects/XNumber.java
+++ b/src/org/apache/xpath/objects/XNumber.java
@@ -23,6 +23,7 @@ package org.apache.xpath.objects;
 import org.apache.xpath.ExpressionOwner;
 import org.apache.xpath.XPathContext;
 import org.apache.xpath.XPathVisitor;
+import org.apache.xpath.xs.types.XSDecimal;
 
 /**
  * This class represents an XPath number, and is capable of
@@ -392,10 +393,11 @@ public class XNumber extends XObject
    */
   public boolean equals(XObject obj2)
   {
-
-    // In order to handle the 'all' semantics of 
-    // nodeset comparisons, we always call the 
-    // nodeset function.
+    
+    if (obj2 instanceof XSDecimal) {
+       return m_val == ((XSDecimal)obj2).doubleValue();   
+    }
+    
     int t = obj2.getType();
     try
     {
diff --git a/src/org/apache/xpath/objects/XObject.java b/src/org/apache/xpath/objects/XObject.java
index c02435c3..bba57e33 100644
--- a/src/org/apache/xpath/objects/XObject.java
+++ b/src/org/apache/xpath/objects/XObject.java
@@ -33,7 +33,8 @@ import org.apache.xpath.XPathContext;
 import org.apache.xpath.XPathException;
 import org.apache.xpath.XPathVisitor;
 import org.apache.xpath.res.XPATHErrorResources;
-
+import org.apache.xpath.xs.types.XSBoolean;
+import org.apache.xpath.xs.types.XSDecimal;
 import org.w3c.dom.DocumentFragment;
 import org.w3c.dom.NodeList;
 import org.w3c.dom.traversal.NodeIterator;
@@ -633,6 +634,13 @@ public class XObject extends Expression implements Serializable, Cloneable
   public boolean equals(XObject obj2)
   {
 
+    if ((this instanceof XSDecimal) && (obj2 instanceof XSDecimal)) {
+       return ((XSDecimal)this).equals((XSDecimal)obj2);        
+    }
+    else if ((this instanceof XSBoolean) && (obj2 instanceof XSBoolean)) {
+       return ((XSBoolean)this).equals((XSBoolean)obj2);    
+    }
+    
     // In order to handle the 'all' semantics of 
     // nodeset comparisons, we always call the 
     // nodeset function.
diff --git a/src/org/apache/xpath/operations/Minus.java b/src/org/apache/xpath/operations/Minus.java
index d750e5e0..0a03cfa3 100644
--- a/src/org/apache/xpath/operations/Minus.java
+++ b/src/org/apache/xpath/operations/Minus.java
@@ -23,6 +23,7 @@ package org.apache.xpath.operations;
 import org.apache.xpath.XPathContext;
 import org.apache.xpath.objects.XNumber;
 import org.apache.xpath.objects.XObject;
+import org.apache.xpath.xs.types.XSDecimal;
 
 /**
  * The binary '-' operation expression executer.
@@ -46,7 +47,33 @@ public class Minus extends Operation
   public XObject operate(XObject left, XObject right)
           throws javax.xml.transform.TransformerException
   {
-    return new XNumber(left.num() - right.num());
+      XObject result = null;
+      
+      double leftArg;
+      double rightArg;
+      
+      if (left instanceof XSDecimal) {
+          leftArg = ((XSDecimal)left).doubleValue();    
+      }
+      else {
+          leftArg = left.num();  
+      }
+      
+      if (right instanceof XSDecimal) {
+          rightArg = ((XSDecimal)right).doubleValue();    
+      }
+      else {
+          rightArg = right.num();  
+      }
+      
+      // by default, format the double value upto two decimal places
+      java.lang.String formattedDblStr = java.lang.String.format("%.2f", 
+                                                              leftArg - rightArg);
+      
+      
+      result = new XNumber((new Double(formattedDblStr)).doubleValue());
+      
+      return result;
   }
   
   /**
diff --git a/src/org/apache/xpath/operations/Plus.java b/src/org/apache/xpath/operations/Plus.java
index 24a918e8..fdac8e32 100644
--- a/src/org/apache/xpath/operations/Plus.java
+++ b/src/org/apache/xpath/operations/Plus.java
@@ -23,6 +23,7 @@ package org.apache.xpath.operations;
 import org.apache.xpath.XPathContext;
 import org.apache.xpath.objects.XNumber;
 import org.apache.xpath.objects.XObject;
+import org.apache.xpath.xs.types.XSDecimal;
 
 /**
  * The '+' operation expression executer.
@@ -45,7 +46,28 @@ public class Plus extends Operation
   public XObject operate(XObject left, XObject right)
           throws javax.xml.transform.TransformerException
   {
-    return new XNumber(left.num() + right.num());
+      XObject result = null;
+      
+      double leftArg;
+      double rightArg;
+      
+      if (left instanceof XSDecimal) {
+          leftArg = ((XSDecimal)left).doubleValue();    
+      }
+      else {
+          leftArg = left.num();  
+      }
+      
+      if (right instanceof XSDecimal) {
+          rightArg = ((XSDecimal)right).doubleValue();    
+      }
+      else {
+          rightArg = right.num();  
+      }
+      
+      result = new XNumber(leftArg + rightArg);
+      
+      return result;
   }
   
   /**
diff --git a/src/org/apache/xpath/res/XPATHErrorResources.java b/src/org/apache/xpath/res/XPATHErrorResources.java
index 8b1863e1..38aa6842 100644
--- a/src/org/apache/xpath/res/XPATHErrorResources.java
+++ b/src/org/apache/xpath/res/XPATHErrorResources.java
@@ -209,9 +209,7 @@ public static final String ER_IGNORABLE_WHITESPACE_NOT_HANDLED =
  public static final String ER_NULL_ERROR_HANDLER = "ER_NULL_ERROR_HANDLER";
    /**  Programmer's assertion: unknown opcode  */
   public static final String ER_PROG_ASSERT_UNKNOWN_OPCODE = 
-	 "ER_PROG_ASSERT_UNKNOWN_OPCODE";
-   /**  0 or 1   */
-  public static final String ER_ZERO_OR_ONE = "ER_ZERO_OR_ONE";
+	 "ER_PROG_ASSERT_UNKNOWN_OPCODE";   
    /**  rtf() not supported by XRTreeFragSelectWrapper   */
   public static final String ER_RTF_NOT_SUPPORTED_XRTREEFRAGSELECTWRAPPER = 
 	 "ER_RTF_NOT_SUPPORTED_XRTREEFRAGSELECTWRAPPER";
@@ -228,8 +226,11 @@ public static final String ER_IGNORABLE_WHITESPACE_NOT_HANDLED =
    /**  The FastStringBuffer argument can not be null   */
  public static final String ER_FASTSTRINGBUFFER_CANNOT_BE_NULL = 
 	 "ER_FASTSTRINGBUFFER_CANNOT_BE_NULL";
+  
   /** 0 */
   public static final String ER_ZERO = "ER_ZERO";
+  /**  0 or 1   */
+  public static final String ER_ZERO_OR_ONE = "ER_ZERO_OR_ONE";
   /** 1 or 2 */
   public static final String ER_ONE_OR_TWO = "ER_ONE_OR_TWO";
    /**  2 or 3   */
@@ -238,6 +239,7 @@ public static final String ER_IGNORABLE_WHITESPACE_NOT_HANDLED =
   public static final String ER_ONE_TWO_OR_THREE = "ER_ONE_TWO_OR_THREE";
   /**  3 or 4   */
   public static final String ER_THREE_OR_FOUR = "ER_THREE_OR_FOUR";
+  
    /** Variable accessed before it is bound! */
   public static final String ER_VARIABLE_ACCESSED_BEFORE_BIND = 
 	 "ER_VARIABLE_ACCESSED_BEFORE_BIND";
@@ -589,9 +591,6 @@ public static final String ER_IGNORABLE_WHITESPACE_NOT_HANDLED =
   { ER_PROG_ASSERT_UNKNOWN_OPCODE,
        "Programmer''s assertion: unknown opcode: {0}"},
 
-  { ER_ZERO_OR_ONE,
-       "0 or 1"},
-
   { ER_RTF_NOT_SUPPORTED_XRTREEFRAGSELECTWRAPPER,
        "rtf() not supported by XRTreeFragSelectWrapper"},
 
@@ -628,6 +627,9 @@ public static final String ER_IGNORABLE_WHITESPACE_NOT_HANDLED =
 
   { ER_ZERO, "0"},
   
+  { ER_ZERO_OR_ONE,
+       "0 or 1"},
+  
   { ER_ONE_OR_TWO,
        "1 or 2"},
   
diff --git a/src/org/apache/xpath/xs/types/XPath3DecimalFormat.java b/src/org/apache/xpath/xs/types/XPath3DecimalFormat.java
new file mode 100644
index 00000000..548e3709
--- /dev/null
+++ b/src/org/apache/xpath/xs/types/XPath3DecimalFormat.java
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.xpath.xs.types;
+
+import java.math.BigDecimal;
+import java.text.DecimalFormat;
+import java.text.DecimalFormatSymbols;
+import java.text.FieldPosition;
+import java.util.Locale;
+
+/**
+ * This class provides an XPath 3.0 specific implementation of decimal 
+ * number string format, to handle few of the XPath specific decimal number 
+ * string formatting requirements.
+ * 
+ * This class extends the Java class java.text.DecimalFormat and inherits 
+ * most of its significant implementation behavior. 
+ * 
+ * @author Mukul Gandhi <mu...@apache.org>
+ * 
+ * @xsl.usage advanced 
+ */
+public class XPath3DecimalFormat extends DecimalFormat {
+
+    private static final long serialVersionUID = 5055460273589749811L;
+
+    private static final String NEG_INFINITY = "-INF";
+	
+	private static final String POS_INFINITY = "INF";
+
+	/*
+	 * Class constructor.
+	 */
+	public XPath3DecimalFormat(String patternStr) {
+		super(patternStr, new DecimalFormatSymbols(Locale.getDefault()));
+	}
+
+	/**
+	 * Format an object representing a number, to a string value.
+	 * 
+	 * @param   numberVal    a number object, that needs to be 
+	 *                       formatted to string 
+	 */
+	public String performStrFormatting(Object numberVal) {
+	    String curPattern = toPattern();
+        String newPattern = curPattern.replaceAll("E0", "");
+        
+        if (numberVal instanceof Float) {
+            return formatFloatValue(numberVal, curPattern, newPattern);
+        }
+        
+        if (numberVal instanceof Double) {
+            return formatDoubleValue(numberVal, curPattern, newPattern);
+        }
+        
+        return super.format(numberVal, new StringBuffer(), new FieldPosition(0)).
+                                                                    toString();
+	}
+	
+	/*
+     * Format a float numeric value, to a string.
+     */
+	private String formatFloatValue(Object floatVal, String curPattern, 
+	                                                          String newPattern) {
+        Float floatValue = (Float) floatVal;
+        
+        if (floatValue.floatValue() == Float.NEGATIVE_INFINITY) {
+            return NEG_INFINITY;
+        }
+        
+        if (floatValue.floatValue() == Float.POSITIVE_INFINITY) {
+            return POS_INFINITY;
+        }        
+        
+        if (floatValue.floatValue() > -1E6f && floatValue.floatValue() < 1E6f) {            
+            applyPattern(newPattern);
+        } 
+        else if (floatValue.floatValue() <= -1E6f) {
+            applyPattern(curPattern.replaceAll("0\\.#", "0.0" ));
+        }
+        
+        return format(floatVal, new StringBuffer(), new FieldPosition(0)).toString();
+    }
+
+	/*
+	 * Format a double numeric value, to a string.
+	 */
+	private String formatDoubleValue(Object doubleVal, String curPattern, 
+	                                                              String newPattern) {
+		Double doubleValue = (Double) doubleVal;
+		
+		if (doubleValue.doubleValue() == Double.NEGATIVE_INFINITY) {
+			return NEG_INFINITY;
+		}
+		
+		if (doubleValue.doubleValue() == Double.POSITIVE_INFINITY) {
+			return POS_INFINITY;
+		}
+		
+		BigDecimal doubValue = new BigDecimal((((Double) doubleVal)).
+		                                                      doubleValue());
+        BigDecimal minValue = new BigDecimal("-1E6");
+        BigDecimal maxValue = new BigDecimal("1E6");
+        
+        if (doubValue.compareTo(minValue) > 0 && doubValue.compareTo(maxValue) < 0) {
+            applyPattern(newPattern);
+        } 
+        else {
+            applyPattern(curPattern.replaceAll("0\\.#", "0.0"));
+        }
+		
+		return format(doubleVal, new StringBuffer(), new FieldPosition(0)).
+		                                                            toString();
+	}
+	
+}
diff --git a/src/org/apache/xpath/xs/types/XSAnyAtomicType.java b/src/org/apache/xpath/xs/types/XSAnyAtomicType.java
index 53cc80ff..ff2f299e 100644
--- a/src/org/apache/xpath/xs/types/XSAnyAtomicType.java
+++ b/src/org/apache/xpath/xs/types/XSAnyAtomicType.java
@@ -20,8 +20,10 @@
  */
 package org.apache.xpath.xs.types;
 
+import org.apache.xpath.objects.ResultSequence;
+
 /**
- * Base class for all the XML Schema atomic types.
+ * Base class for all the XML Schema atomic data types.
  * 
  * @author Mukul Gandhi <mu...@apache.org>
  * 
@@ -29,4 +31,20 @@ package org.apache.xpath.xs.types;
  */
 public abstract class XSAnyAtomicType extends XSAnySimpleType {
     
+    private static final long serialVersionUID = 4800376096762047151L;
+
+    /*
+     * This function supports, creating XML Schema built-in types, XPath 3.1
+     * XDM objects with data types xs:boolean, xs:decimal etc.
+     * 
+     */
+    public abstract ResultSequence constructor(ResultSequence arg);
+    
+    /**
+     * Get the datatype's name
+     * 
+     * @return  String representation of the datatype's name
+     */
+    public abstract String typeName();
+    
 }
diff --git a/src/org/apache/xpath/xs/types/XSAnyType.java b/src/org/apache/xpath/xs/types/XSAnyType.java
index e1041c1e..4d7a99bf 100644
--- a/src/org/apache/xpath/xs/types/XSAnyType.java
+++ b/src/org/apache/xpath/xs/types/XSAnyType.java
@@ -15,16 +15,17 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-/*
- * $Id$
- */
 package org.apache.xpath.xs.types;
 
+import org.apache.xml.utils.FastStringBuffer;
 import org.apache.xpath.objects.XObject;
 
 /**
  * Base class for all the XML Schema types.
  * 
+ * (please refer, https://www.w3.org/TR/xmlschema11-2/#built-in-datatypes
+ *  that illustrates the XML Schema 1.1 built-in datatypes hierarchy)
+ * 
  * @author Mukul Gandhi <mu...@apache.org>
  * 
  * @xsl.usage advanced
@@ -34,7 +35,7 @@ public abstract class XSAnyType extends XObject {
     private static final long serialVersionUID = -3385975335330221518L;
 
     /**
-	 * Get the datatype's name, for e.g "xs:boolean".
+	 * Get the datatype's name. For e.g "xs:boolean", "xs:decimal".
 	 * 
 	 * @return datatype's name
 	 */
@@ -48,7 +49,7 @@ public abstract class XSAnyType extends XObject {
 	 */
 	public abstract String stringValue();
 	
-	public void appendToFsb(org.apache.xml.utils.FastStringBuffer fsb) {
+	public void appendToFsb(FastStringBuffer fsb) {
 	   fsb.append(stringValue());
 	} 
 	
diff --git a/src/org/apache/xpath/xs/types/XSBoolean.java b/src/org/apache/xpath/xs/types/XSBoolean.java
new file mode 100644
index 00000000..94589a87
--- /dev/null
+++ b/src/org/apache/xpath/xs/types/XSBoolean.java
@@ -0,0 +1,116 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.xpath.xs.types;
+
+import org.apache.xpath.objects.ResultSequence;
+
+/**
+ * An XML Schema data type representation, of the xs:boolean datatype.
+ * 
+ * We've this data type implementation, equivalent to XalanJ's legacy 
+ * data type implementation org.apache.xpath.objects.XBoolean for boolean 
+ * values. We may use, both of these classes for XalanJ's needs.
+ * 
+ * @author Mukul Gandhi <mu...@apache.org>
+ * 
+ * @xsl.usage advanced
+ */
+public class XSBoolean extends XSCtrType {
+
+    private static final long serialVersionUID = -8635660165145453378L;
+
+    private static final String XS_BOOLEAN = "xs:boolean";
+    
+    private boolean _value;
+    
+    /*
+     * Class constructor.
+    */
+    public XSBoolean(boolean bool) {
+        _value = bool;
+    }
+
+    /*
+     * Class constructor.
+    */
+    public XSBoolean() {
+        this(false);
+    }
+
+    @Override
+    public ResultSequence constructor(ResultSequence arg) {        
+        ResultSequence resultSeq = new ResultSequence();
+        
+        if (arg.size() == 0) {
+           return resultSeq;     
+        }
+        
+        XSAnyType xsAnyType = (XSAnyType)arg.item(0);
+        String strVal = xsAnyType.stringValue();
+           
+        Boolean bool = null;
+        if (isBooleanFalse(strVal)) {
+           bool = Boolean.FALSE;    
+        }
+        else {
+           bool = Boolean.TRUE;     
+        }
+           
+        resultSeq.add(new XSBoolean(bool.booleanValue()));
+           
+        return resultSeq;        
+    }
+
+    @Override
+    public String typeName() {
+        return "boolean";
+    }
+
+    @Override
+    public String stringType() {
+        return XS_BOOLEAN;
+    }
+
+    @Override
+    public String stringValue() {
+        return "" + _value;
+    }
+    
+    /**
+     * Get the actual boolean value stored, within this object.
+     * 
+     * @return   the actual boolean value stored
+     */
+    public boolean value() {
+        return _value;
+    }
+    
+    public boolean equals(XSBoolean xsBoolean) {
+        return _value == xsBoolean.value();  
+    }
+    
+    /*
+     * Check whether, a string value represents a boolean 
+     * 'false' value.
+     */
+    private boolean isBooleanFalse(String strVal) {
+        return strVal.equals("0") || strVal.equals("false") ||
+                 strVal.equals("+0") || strVal.equals("-0") ||
+                 strVal.equals("0.0E0") || strVal.equals("NaN");
+    }
+
+}
diff --git a/src/org/apache/xpath/xs/types/XSCtrType.java b/src/org/apache/xpath/xs/types/XSCtrType.java
index 09e70178..c4e013ea 100644
--- a/src/org/apache/xpath/xs/types/XSCtrType.java
+++ b/src/org/apache/xpath/xs/types/XSCtrType.java
@@ -25,7 +25,10 @@ import org.apache.xpath.objects.ResultSequence;
 /**
  * A representation of the XSCtrType datatype.
  * 
- * This data type is used for, XML Schema data type constructor functions.
+ * All the XML Schema built-in types that have constructor functions
+ * as defined by XPath 3.1 F&O spec, XalanJ data type classes for those 
+ * XML Schema built-in types have this class as a parent or an ancestor 
+ * class.
  * 
  * @author Mukul Gandhi <mu...@apache.org>
  * 
@@ -33,17 +36,23 @@ import org.apache.xpath.objects.ResultSequence;
  */
 public abstract class XSCtrType extends XSAnyAtomicType {
 
-	/**
-	 * Used for constructor functions.
+    private static final long serialVersionUID = -1177633885817069140L;
+
+    /**
+	 * This function is used for, XML Schema built-in types 
+	 * constructor functions.
 	 * 
-	 * @param arg   either an empty sequence, or an XML Schema atomic type
+	 * For e.g, xs:string($arg as xs:anyAtomicType?) as xs:string? ,
+	 *          xs:boolean($arg as xs:anyAtomicType?) as xs:boolean? etc
+	 *          
+	 * @param arg    either an empty sequence, or an XML Schema atomic type
 	 * 
-	 * @return      the resulting ResultSequence
+	 * @return       the resulting ResultSequence
 	 */
 	public abstract ResultSequence constructor(ResultSequence arg);
 
 	/**
-	 * Get the datatype's name
+	 * Get the datatype's name.
 	 * 
 	 * @return String representation of the datatype's name
 	 */
diff --git a/src/org/apache/xpath/xs/types/XSDecimal.java b/src/org/apache/xpath/xs/types/XSDecimal.java
new file mode 100644
index 00000000..b020bb09
--- /dev/null
+++ b/src/org/apache/xpath/xs/types/XSDecimal.java
@@ -0,0 +1,157 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.xpath.xs.types;
+
+import java.math.BigDecimal;
+
+import org.apache.xpath.objects.ResultSequence;
+
+/**
+ * An XML Schema data type representation, of the xs:decimal datatype.
+ * 
+ * @author Mukul Gandhi <mu...@apache.org>
+ * 
+ * @xsl.usage advanced
+ */
+public class XSDecimal extends XSNumericType {
+
+    private static final long serialVersionUID = 3338738472846690263L;
+    
+    private static final String XS_DECIMAL = "xs:decimal";
+    
+    private BigDecimal _value;
+    
+    private XPath3DecimalFormat xpath3DecimalFormat = new XPath3DecimalFormat(
+                                                                 "0.####################");
+    
+    /**
+     * Class constructor.
+     */
+    public XSDecimal() {
+       this(BigDecimal.valueOf(0));
+    }
+    
+    /**
+     * Class constructor.
+     */
+    public XSDecimal(BigDecimal bigDecimal) {
+       _value = bigDecimal; 
+    }
+    
+    /**
+     * Class constructor.
+     */
+    public XSDecimal(String str) {
+        _value = new BigDecimal(str);
+    }
+
+    @Override
+    public String stringType() {
+        return XS_DECIMAL;
+    }
+    
+    public String typeName() {
+        return "decimal";
+    }
+
+    @Override
+    public String stringValue() {
+        if (zero()) {
+           return "0";
+        }
+
+        _value = new BigDecimal((_value.toString()).replaceFirst("0*", ""));
+        
+        return xpath3DecimalFormat.performStrFormatting(_value);
+    }
+    
+    @Override
+    public ResultSequence constructor(ResultSequence arg) {
+        ResultSequence resultSeq = new ResultSequence();
+        
+        if (arg.size() == 0) {
+           return resultSeq;     
+        }
+        
+        XSAnyType xsAnyType = (XSAnyType)arg.item(0);
+        
+        try {            
+            XSDecimal xsDecimal = castToDecimal(xsAnyType);            
+            resultSeq.add(xsDecimal);
+        } catch (NumberFormatException e) {
+            // to do
+            return null;
+        }        
+        
+        return resultSeq;
+    }
+    
+    /**
+     * Check if this XSDecimal object represents the value 0.
+     * 
+     * @return    true if this XSDecimal object represents the value 0. 
+     *            false otherwise.
+     */
+    public boolean zero() {
+        return (_value.compareTo(new BigDecimal(0.0)) == 0);
+    }
+    
+    /**
+     * Get the actual value of the number stored within 
+     * this XSDecimal object.
+     * 
+     * @return   the actual value of the number stored
+     */
+    public double doubleValue() {
+        return _value.doubleValue();
+    }
+    
+    public BigDecimal getValue() {
+        return _value;
+    }
+    
+    /**
+     * Set the numeric double value, within this XSDecimal object.
+     * 
+     * @param val    number to be stored
+     */
+    public void setDouble(double val) {
+        _value = new BigDecimal(val);
+    }
+    
+    public boolean equals(XSDecimal xsDecimal) {
+        return _value.equals(xsDecimal.getValue()); 
+    }
+    
+    /*
+     * Cast an object of type XSAnyType, to an object of type 
+     * XSDecimal.  
+     */
+    private XSDecimal castToDecimal(XSAnyType xsAnyType) {        
+       if (xsAnyType instanceof XSBoolean) {            
+          if ((xsAnyType.stringValue()).equals("true")) {
+             return new XSDecimal(new BigDecimal("1"));
+          } 
+          else {
+             return new XSDecimal(new BigDecimal("0"));
+          }
+       }
+        
+       return new XSDecimal(xsAnyType.stringValue());
+    }
+
+}
diff --git a/src/org/apache/xpath/xs/types/XSDouble.java b/src/org/apache/xpath/xs/types/XSDouble.java
new file mode 100644
index 00000000..cc0a94ea
--- /dev/null
+++ b/src/org/apache/xpath/xs/types/XSDouble.java
@@ -0,0 +1,170 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.xpath.xs.types;
+
+import org.apache.xpath.objects.ResultSequence;
+
+/**
+ * An XML Schema data type representation, of the xs:double datatype.
+ * 
+ * @author Mukul Gandhi <mu...@apache.org>
+ * 
+ * @xsl.usage advanced
+ */
+public class XSDouble extends XSNumericType {
+
+    private static final long serialVersionUID = -2666052244390163961L;
+
+    private static final String XS_DOUBLE = "xs:double";
+	
+	private Double _value;
+	
+	private XPath3DecimalFormat xpath3DecimalFormat = new XPath3DecimalFormat(
+	                                                              "0.################E0");
+
+	/*
+	 * Class constructor.
+	 */
+	public XSDouble(double val) {
+	    _value = new Double(val);
+	}
+
+	/*
+     * Class constructor.
+     */
+	public XSDouble() {
+	    this(0);
+	}
+
+	/*
+     * Class constructor.
+     */
+	public XSDouble(String val) {
+		try {
+			if (val.equals("-INF")) {
+				_value = new Double(Double.NEGATIVE_INFINITY);
+			} else if (val.equals("INF")) {
+				_value = new Double(Double.POSITIVE_INFINITY);
+			} else {
+				_value = new Double(val);
+			}
+		} catch (NumberFormatException ex) {
+			// to do
+		}
+	}
+
+	/**
+	 * Get a XSDouble object, corresponding to the string valued 
+	 * argument provided.
+	 * 
+	 * @param str   string value, to be parsed to an XSDouble object
+	 * 
+	 * @return      an XSDouble object, corresponding to the string
+	 *              argument provided.
+	 */
+	public static XSDouble parseDouble(String str) {	    
+		try {
+			Double d1 = null;
+			
+			if (str.equals("INF")) {
+				d1 = new Double(Double.POSITIVE_INFINITY);
+			} else if (str.equals("-INF")) {
+				d1 = new Double(Double.NEGATIVE_INFINITY);
+			} else {
+				d1 = new Double(str);
+			}
+			
+			return new XSDouble(d1.doubleValue());			
+		} catch (NumberFormatException ex) {
+			return null;
+		}		
+	}
+	
+	@Override
+    public ResultSequence constructor(ResultSequence arg) {
+        // to do
+        return null;
+    }
+
+    @Override
+    public String typeName() {
+        return "double";
+    }
+
+    @Override
+    public String stringType() {
+        return XS_DOUBLE;
+    }
+
+    @Override
+    public String stringValue() {
+        if (zero()) {
+            return "0";
+        }
+
+        if (negativeZero()) {
+            return "-0";
+        }
+
+        if (nan()) {
+            return "NaN";
+        }
+
+        return xpath3DecimalFormat.performStrFormatting(_value);
+    }
+    
+    /*
+     * Check whether this XSDouble object represents -0.
+     * 
+     * @return    true if this XSDouble object represents -0.
+     *            false otherwise.
+     */
+    public boolean negativeZero() {
+        return (Double.compare(_value.doubleValue(), -0.0E0) == 0);
+    }
+
+    /**
+     * Get the actual double primitive value, corresponding to 
+     * this XSDouble object.
+     */
+    public double doubleValue() {
+        return _value.doubleValue();
+    }
+    
+    /**
+     * Check whether this XSDouble object represents NaN.
+     */
+    public boolean nan() {
+        return Double.isNaN(_value.doubleValue());
+    }
+
+    /**
+     * Check whether this XSDouble object represents an 
+     * infinite number.
+     */
+    public boolean infinite() {
+        return Double.isInfinite(_value.doubleValue());
+    }
+
+    /**
+     * Check whether this XSDouble object represents 0.
+     */
+    public boolean zero() {
+        return (Double.compare(_value.doubleValue(), 0.0E0) == 0);
+    }
+    
+}
diff --git a/src/org/apache/xpath/xs/types/XSFloat.java b/src/org/apache/xpath/xs/types/XSFloat.java
new file mode 100644
index 00000000..1fb4c3a8
--- /dev/null
+++ b/src/org/apache/xpath/xs/types/XSFloat.java
@@ -0,0 +1,153 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.xpath.xs.types;
+
+import org.apache.xpath.objects.ResultSequence;
+
+/**
+ * An XML Schema data type representation, of the xs:float datatype.
+ * 
+ * @author Mukul Gandhi <mu...@apache.org>
+ * 
+ * @xsl.usage advanced
+ */
+public class XSFloat extends XSNumericType {
+
+    private static final long serialVersionUID = 7301295458418107791L;
+
+    private static final String XS_FLOAT = "xs:float";
+	
+	private Float _value;
+	
+	private XPath3DecimalFormat xpath3DecimalFormat = new XPath3DecimalFormat(
+	                                                                   "0.#######E0");
+	
+	/*
+	 * Class constructor.
+	 */
+	public XSFloat(float x) {
+		_value = new Float(x);
+	}
+
+	/*
+     * Class constructor.
+     */
+	public XSFloat() {
+		this(0);
+	}
+
+	/*
+     * Class constructor.
+     */
+	public XSFloat(String val) {
+		try {
+	       if (val.equals("-INF")) {
+			  _value = new Float(Float.NEGATIVE_INFINITY);
+		   } else if (val.equals("INF")) {
+			  _value = new Float(Float.POSITIVE_INFINITY);
+		   } else {
+		      _value = new Float(val);
+		   }
+		} catch (NumberFormatException ex) {
+			// to do
+		}
+	}
+	
+	public String stringType() {
+		return XS_FLOAT;
+	}
+
+	public String typeName() {
+		return "float";
+	}
+
+	@Override
+	public String stringValue() {	   
+	   if (zero()) {
+	      return "0";
+	   }
+	   
+	   if (negativeZero()) {
+	      return "-0"; 
+	   }
+	        
+	   if (nan()) {
+	      return "NaN";    
+	   }
+	                                
+	   return xpath3DecimalFormat.performStrFormatting(_value);
+	}
+	
+	@Override
+    public ResultSequence constructor(ResultSequence arg) {
+        // to do
+        return null;
+    }
+
+	/**
+	 * Check whether, value of this numeric float object 
+	 * represents NaN.
+	 * 
+	 * @return     true if this numeric float object represents NaN.
+	 *             false otherwise.
+	 */
+	public boolean nan() {
+		return Float.isNaN(_value.floatValue());
+	}
+
+	/**
+	 * Check whether this float object, represents negative or positive 
+	 * infinity.
+	 * 
+	 * @return    true is this float object represents infinity.
+	 *            false otherwise.
+	 */
+	public boolean infinite() {
+		return Float.isInfinite(_value.floatValue());
+	}
+
+	/**
+	 * Check whether this numeric float object represents 0.
+	 * 
+	 * @return    true if this numeric float object represents 0.
+	 *            false otherwise.
+	 */
+	public boolean zero() {
+	   return (Float.compare(_value.floatValue(), 0) == 0);
+	}
+	
+	/*
+	 * Check whether this numeric float object, represents -0.
+	 * 
+	 * @return   true if this numeric float object represents -0.
+	 *           false otherwise.
+	 */
+	public boolean negativeZero() {
+	   return (Float.compare(_value.floatValue(), -0.0f) == 0);
+	}
+	
+	/**
+	 * Get the actual numeric float value stored, within this 
+	 * object.
+	 * 
+	 * @return    the actual numeric float value stored
+	 */
+	public float floatValue() {
+		return _value.floatValue();
+	}	
+	
+}
diff --git a/src/org/apache/xpath/xs/types/XSCtrType.java b/src/org/apache/xpath/xs/types/XSInt.java
similarity index 60%
copy from src/org/apache/xpath/xs/types/XSCtrType.java
copy to src/org/apache/xpath/xs/types/XSInt.java
index 09e70178..19e47959 100644
--- a/src/org/apache/xpath/xs/types/XSCtrType.java
+++ b/src/org/apache/xpath/xs/types/XSInt.java
@@ -15,38 +15,51 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-/*
- * $Id$
- */
 package org.apache.xpath.xs.types;
 
+import java.math.BigInteger;
+
 import org.apache.xpath.objects.ResultSequence;
 
 /**
- * A representation of the XSCtrType datatype.
- * 
- * This data type is used for, XML Schema data type constructor functions.
+ * An XML Schema data type representation, of the xs:int datatype.
  * 
  * @author Mukul Gandhi <mu...@apache.org>
  * 
  * @xsl.usage advanced
  */
-public abstract class XSCtrType extends XSAnyAtomicType {
-
-	/**
-	 * Used for constructor functions.
-	 * 
-	 * @param arg   either an empty sequence, or an XML Schema atomic type
-	 * 
-	 * @return      the resulting ResultSequence
-	 */
-	public abstract ResultSequence constructor(ResultSequence arg);
+public class XSInt extends XSLong {
 
-	/**
-	 * Get the datatype's name
-	 * 
-	 * @return String representation of the datatype's name
+    private static final long serialVersionUID = -6853519104620633955L;
+    
+    private static final String XS_INT = "xs:int";
+    
+	/*
+	 * Class constructor.
 	 */
-	public abstract String typeName();
+	public XSInt() {
+	  this(BigInteger.valueOf(0));
+	}
+	
+	/*
+     * Class constructor.
+     */
+	public XSInt(BigInteger val) {
+		super(val);
+	}
+	
+	@Override
+    public ResultSequence constructor(ResultSequence arg) {
+       // to do
+       return null;
+    }
+	
+	public String stringType() {
+		return XS_INT;
+	}
+	
+	public String typeName() {
+		return "int";
+	}
 	
 }
diff --git a/src/org/apache/xpath/xs/types/XSInteger.java b/src/org/apache/xpath/xs/types/XSInteger.java
new file mode 100644
index 00000000..687d6868
--- /dev/null
+++ b/src/org/apache/xpath/xs/types/XSInteger.java
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.xpath.xs.types;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
+import org.apache.xpath.objects.ResultSequence;
+
+/**
+ * An XML Schema data type representation, of the xs:integer datatype.
+ * 
+ * @author Mukul Gandhi <mu...@apache.org>
+ * 
+ * @xsl.usage advanced
+ */
+public class XSInteger extends XSDecimal {
+
+    private static final long serialVersionUID = -4634168510820898744L;
+
+    private static final String XS_INTEGER = "xs:integer";
+	
+	private BigInteger _value;
+
+	/*
+	 * Class constructor.
+	 */
+	public XSInteger() {
+		this(BigInteger.valueOf(0));
+	}
+
+	/*
+     * Class constructor.
+     */
+	public XSInteger(BigInteger val) {
+		super(new BigDecimal(val));
+		_value = val;
+	}
+
+	/*
+     * Class constructor.
+     */
+	public XSInteger(String val) {
+		super(new BigDecimal(val));
+		_value = new BigInteger(val);
+	}
+
+	public String stringType() {
+		return XS_INTEGER;
+	}
+
+	public String typeName() {
+		return "integer";
+	}
+
+	/**
+	 * Get a string representation of an integer value stored, 
+	 * within this object.
+	 * 
+	 * @return   string representation of the integer value stored
+	 */
+	public String stringValue() {
+		return _value.toString();
+	}
+
+	/**
+     * Check if this XSInteger object represents the value 0.
+     * 
+     * @return    true if this XSInteger object represents the value 0. 
+     *            false otherwise.
+     */
+	public boolean zero() {
+		return (_value.compareTo(BigInteger.ZERO) == 0);
+	}
+
+	public ResultSequence constructor(ResultSequence arg) {
+	    // to do
+        return null;
+	}
+
+	/**
+     * Get the actual value of an integer number stored within 
+     * this object.
+     * 
+     * @return   the actual value of the number stored
+     */
+	public BigInteger intValue() {
+		return _value;
+	}
+
+	/**
+     * Set the numeric integer value, within this object.
+     * 
+     * @param val    number to be stored
+     */
+	public void setInt(BigInteger val) {
+		_value = val;
+	}
+
+}
diff --git a/src/org/apache/xpath/xs/types/XSLong.java b/src/org/apache/xpath/xs/types/XSLong.java
new file mode 100644
index 00000000..e241f950
--- /dev/null
+++ b/src/org/apache/xpath/xs/types/XSLong.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.xpath.xs.types;
+
+import java.math.BigInteger;
+
+import org.apache.xpath.objects.ResultSequence;
+
+/**
+ * An XML Schema data type representation, of the xs:long datatype.
+ * 
+ * @author Mukul Gandhi <mu...@apache.org>
+ * 
+ * @xsl.usage advanced
+ */
+public class XSLong extends XSInteger {
+
+    private static final long serialVersionUID = -1030394161532436404L;
+    
+    private static final String XS_LONG = "xs:long";
+
+	/*
+	 * Class constructor.
+	 */
+	public XSLong() {
+	   this(BigInteger.valueOf(0));
+	}
+	
+	/*
+     * Class constructor.
+     */
+	public XSLong(BigInteger val) {
+		super(val);
+	}
+	
+	@Override
+    public ResultSequence constructor(ResultSequence arg) {
+       // to do
+       return null;
+    }
+	
+	public String stringType() {
+		return XS_LONG;
+	}
+	
+	public String typeName() {
+		return "long";
+	}
+
+}
diff --git a/src/org/apache/xpath/xs/types/XSNumericType.java b/src/org/apache/xpath/xs/types/XSNumericType.java
new file mode 100644
index 00000000..502d2cff
--- /dev/null
+++ b/src/org/apache/xpath/xs/types/XSNumericType.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.xpath.xs.types;
+
+import org.apache.xpath.objects.ResultSequence;
+
+/**
+ * This class serves as base type, of all the XML Schema built-in 
+ * numeric types.
+ * 
+ * @author Mukul Gandhi <mu...@apache.org>
+ * 
+ * @xsl.usage advanced
+ */
+public class XSNumericType extends XSCtrType {
+
+    private static final long serialVersionUID = 6842313858622701811L;
+
+    @Override
+    public ResultSequence constructor(ResultSequence arg) {
+        return null;
+    }
+
+    @Override
+    public String typeName() {
+        return null;
+    }
+
+    @Override
+    public String stringType() {
+        return null;
+    }
+
+    @Override
+    public String stringValue() {
+        return null;
+    }
+
+}
diff --git a/tests/fn_abs/test1.xsl b/tests/fn_abs/test1.xsl
index bf9719d6..3fe2ff70 100644
--- a/tests/fn_abs/test1.xsl
+++ b/tests/fn_abs/test1.xsl
@@ -21,14 +21,14 @@
            </xsl:for-each>
          </result1>
          <result2>
-	   <xsl:for-each select="a">
-	     <item><xsl:value-of select="abs()"/></item>
-	   </xsl:for-each>
+	        <xsl:for-each select="a">
+	           <item><xsl:value-of select="abs()"/></item>
+	        </xsl:for-each>
          </result2>
          <result3>
             <xsl:for-each select="/elem/a[abs() &gt; 7]">
-	      <item><xsl:value-of select="."/></item>
-	    </xsl:for-each>
+	           <item><xsl:value-of select="."/></item>
+	        </xsl:for-each>
          </result3>
          <extra_elem1><xsl:value-of select="a[2] &lt; 0"/></extra_elem1>
          <extra_elem2><xsl:value-of select="a[2] &gt; 0"/></extra_elem2>
diff --git a/tests/org/apache/xalan/xpath3/XsConstructorFunctions.java b/tests/org/apache/xalan/xpath3/XsConstructorFunctions.java
new file mode 100644
index 00000000..30bf61c6
--- /dev/null
+++ b/tests/org/apache/xalan/xpath3/XsConstructorFunctions.java
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.xalan.xpath3;
+
+import org.apache.xalan.util.XslTransformTestsUtil;
+import org.apache.xalan.xslt3.XSLConstants;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * XML Schema built-in types, XPath 3.1 constructor 
+ * functions tests.
+ * 
+ * @author Mukul Gandhi <mu...@apache.org>
+ * 
+ * @xsl.usage advanced
+ */
+public class XsConstructorFunctions extends XslTransformTestsUtil {        
+    
+    private static final String XSL_TRANSFORM_INPUT_DIRPATH = XSLConstants.XSL_TRANSFORM_INPUT_DIRPATH_PREFIX + "xs_constructor_functions/";
+    
+    private static final String XSL_TRANSFORM_GOLD_DIRPATH = XSLConstants.XSL_TRANSFORM_GOLD_DIRPATH_PREFIX + "xs_constructor_functions/gold/";
+
+    @BeforeClass
+    public static void setUpBeforeClass() throws Exception {
+        // no op
+    }
+
+    @AfterClass
+    public static void tearDownAfterClass() throws Exception {        
+        xmlDocumentBuilderFactory = null;
+        xmlDocumentBuilder = null;
+        xslTransformerFactory = null;
+    }
+
+    @Test
+    public void XsConstructorFunctionsTest1() {
+        String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test1.xsl"; 
+        String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test1.xsl";
+        
+        String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test1.out";                
+        
+        runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+    }
+    
+    @Test
+    public void XsConstructorFunctionsTest2() {
+        String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test2.xsl"; 
+        String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test2.xsl";
+        
+        String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test2.out";                
+        
+        runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+    }
+    
+    @Test
+    public void XslTransformTest3() {
+        String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test1_a.xml"; 
+        String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test3.xsl";
+        
+        String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test3.out";                
+        
+        runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+    }
+    
+    @Test
+    public void XsConstructorFunctionsTest4() {
+        String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test1_a.xml"; 
+        String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test4.xsl";
+        
+        String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test4.out";                
+        
+        runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+    }
+    
+    @Test
+    public void XsConstructorFunctionsTest5() {
+        String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test1_a.xml"; 
+        String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test5.xsl";
+        
+        String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test5.out";                
+        
+        runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+    }
+    
+    @Test
+    public void XsConstructorFunctionsTest6() {
+        String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test6.xsl"; 
+        String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test6.xsl";
+        
+        String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test6.out";                
+        
+        runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+    }
+
+}
diff --git a/tests/org/apache/xalan/xslt3/AllXsl3Tests.java b/tests/org/apache/xalan/xslt3/AllXsl3Tests.java
index 9ff8936c..ab1205a8 100644
--- a/tests/org/apache/xalan/xslt3/AllXsl3Tests.java
+++ b/tests/org/apache/xalan/xslt3/AllXsl3Tests.java
@@ -21,6 +21,7 @@ import org.apache.xalan.xpath3.FnStringJoinTests;
 import org.apache.xalan.xpath3.FnTokenizeTests;
 import org.apache.xalan.xpath3.FnUnparsedTextTests;
 import org.apache.xalan.xpath3.StringTests;
+import org.apache.xalan.xpath3.XsConstructorFunctions;
 import org.junit.runner.RunWith;
 import org.junit.runners.Suite;
 import org.junit.runners.Suite.SuiteClasses;
@@ -33,15 +34,15 @@ import org.junit.runners.Suite.SuiteClasses;
  * @xsl.usage advanced
  */
 /*
- *  For all the tests supported by this junit test suite, the XSLT transformation
- *  expected output files (i.e, the gold files) are sensitive to the whitespace
- *  contents available within those files.
+ *  For all the XSLT and XPath tests supported by this test suite, 
+ *  the XSLT transformation expected output files (i.e, the gold files) are 
+ *  sensitive to the whitespace contents available within those files.
  */
 @RunWith(Suite.class)
 @SuiteClasses({ AnalyzeStringTests.class, AttributeTests.class, GroupingTests.class,
-                GroupingWithSortTests.class, RtfMigrationTests.class, 
+                GroupingWithSortTests.class, RtfMigrationTests.class, QuantifiedExprTests.class, 
                 FnUnparsedTextTests.class, FnTokenizeTests.class, FnStringJoinTests.class,
-                FnAbsTests.class, StringTests.class, QuantifiedExprTests.class })
+                FnAbsTests.class, StringTests.class, XsConstructorFunctions.class })
 public class AllXsl3Tests {
 
 }
diff --git a/tests/xs_constructor_functions/gold/test1.out b/tests/xs_constructor_functions/gold/test1.out
new file mode 100644
index 00000000..576edd00
--- /dev/null
+++ b/tests/xs_constructor_functions/gold/test1.out
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?><result>
+  <one>12.23</one>
+  <two>12.23</two>
+  <three>true</three>
+  <four>true</four>
+  <five>false</five>
+  <six>12.23</six>
+  <seven>12.2</seven>
+  <eight>true</eight>
+  <nine>false</nine>
+</result>
diff --git a/tests/xs_constructor_functions/gold/test2.out b/tests/xs_constructor_functions/gold/test2.out
new file mode 100644
index 00000000..59bdbf66
--- /dev/null
+++ b/tests/xs_constructor_functions/gold/test2.out
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?><result>
+  <one>false</one>
+  <two>true</two>
+  <three>true</three>
+  <four>false</four>
+  <five>false</five>
+  <six>true</six>
+  <seven>true</seven>
+  <eight>false</eight>
+</result>
diff --git a/tests/xs_constructor_functions/gold/test3.out b/tests/xs_constructor_functions/gold/test3.out
new file mode 100644
index 00000000..05e5bb77
--- /dev/null
+++ b/tests/xs_constructor_functions/gold/test3.out
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?><result>
+  <one>true</one>
+  <two>false</two>
+</result>
diff --git a/tests/xs_constructor_functions/gold/test4.out b/tests/xs_constructor_functions/gold/test4.out
new file mode 100644
index 00000000..5163ca52
--- /dev/null
+++ b/tests/xs_constructor_functions/gold/test4.out
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?><result>
+  <one>true</one>
+  <two>false</two>
+  <three>true</three>
+  <four>false</four>
+</result>
diff --git a/tests/xs_constructor_functions/gold/test5.out b/tests/xs_constructor_functions/gold/test5.out
new file mode 100644
index 00000000..63a67c88
--- /dev/null
+++ b/tests/xs_constructor_functions/gold/test5.out
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?><result>
+  <one>0.1</one>
+  <two>true</two>
+  <three>false</three>
+  <four>true</four>
+  <five>0.22</five>
+</result>
diff --git a/tests/xs_constructor_functions/gold/test6.out b/tests/xs_constructor_functions/gold/test6.out
new file mode 100644
index 00000000..6b50473c
--- /dev/null
+++ b/tests/xs_constructor_functions/gold/test6.out
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?><result>
+  <one>24.43</one>
+  <two>24.43</two>
+  <three>true</three>
+</result>
diff --git a/tests/fn_abs/test1.xsl b/tests/xs_constructor_functions/test1.xsl
similarity index 50%
copy from tests/fn_abs/test1.xsl
copy to tests/xs_constructor_functions/test1.xsl
index bf9719d6..76710a9e 100644
--- a/tests/fn_abs/test1.xsl
+++ b/tests/xs_constructor_functions/test1.xsl
@@ -1,40 +1,30 @@
 <?xml version="1.0"?>
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                xmlns:xs="http://www.w3.org/2001/XMLSchema"
+                exclude-result-prefixes="xs"
                 version="3.0">
                 
    <!-- Author: mukulg@apache.org -->
    
-   <!-- use with test1_a.xml -->
-   
-   <!-- test for the XPath 3.1 fn:abs() function -->
+   <!-- this stylesheet, tests XPath 3.1 constructor function xs:decimal(),
+        and use of logical operations on such values. -->                
 
    <xsl:output method="xml" indent="yes"/>
 
-   <xsl:template match="/elem">
-      <elem>
-         <item><xsl:value-of select="abs(5)"/></item>
-         <item><xsl:value-of select="abs(-5)"/></item>
-         <item><xsl:value-of select="abs(-2.7)"/></item>
-         <result1>
-           <xsl:for-each select="a">
-              <item><xsl:value-of select="abs(.)"/></item>
-           </xsl:for-each>
-         </result1>
-         <result2>
-	   <xsl:for-each select="a">
-	     <item><xsl:value-of select="abs()"/></item>
-	   </xsl:for-each>
-         </result2>
-         <result3>
-            <xsl:for-each select="/elem/a[abs() &gt; 7]">
-	      <item><xsl:value-of select="."/></item>
-	    </xsl:for-each>
-         </result3>
-         <extra_elem1><xsl:value-of select="a[2] &lt; 0"/></extra_elem1>
-         <extra_elem2><xsl:value-of select="a[2] &gt; 0"/></extra_elem2>
-         <extra_elem3><xsl:value-of select="abs(a[2]) &gt; 7"/></extra_elem3>
-         <extra_elem4><xsl:value-of select="abs(a[2]) &lt; 7"/></extra_elem4>
-      </elem>
+   <xsl:template match="/">
+      <xsl:variable name="decimal1" select="xs:decimal(12.23)"/>
+      <xsl:variable name="decimal2" select="xs:decimal(12.2)"/>
+      <result>
+         <one><xsl:value-of select="xs:decimal(12.23)"/></one>
+         <two><xsl:value-of select="xs:decimal('12.23')"/></two>
+         <three><xsl:value-of select="xs:decimal(12.23) = xs:decimal(12.23)"/></three>
+         <four><xsl:value-of select="xs:decimal(12.23) = xs:decimal('12.23')"/></four>
+         <five><xsl:value-of select="xs:decimal(12.23) = xs:decimal(12.2)"/></five>
+         <six><xsl:value-of select="$decimal1"/></six>
+	     <seven><xsl:value-of select="$decimal2"/></seven>
+	     <eight><xsl:value-of select="$decimal1 = $decimal1"/></eight>
+         <nine><xsl:value-of select="$decimal1 = $decimal2"/></nine>
+      </result>
    </xsl:template>
    
    <!--
diff --git a/tests/xs_constructor_functions/test1_a.xml b/tests/xs_constructor_functions/test1_a.xml
new file mode 100644
index 00000000..a3fe5e74
--- /dev/null
+++ b/tests/xs_constructor_functions/test1_a.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<elem>
+  <a>1.2</a>
+  <b>1.3</b>
+  <c>2.5</c>
+  <d>3.0</d>
+</elem>
\ No newline at end of file
diff --git a/tests/fn_abs/test1.xsl b/tests/xs_constructor_functions/test2.xsl
similarity index 50%
copy from tests/fn_abs/test1.xsl
copy to tests/xs_constructor_functions/test2.xsl
index bf9719d6..c61ce726 100644
--- a/tests/fn_abs/test1.xsl
+++ b/tests/xs_constructor_functions/test2.xsl
@@ -1,40 +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"
+                exclude-result-prefixes="xs"
                 version="3.0">
                 
    <!-- Author: mukulg@apache.org -->
    
-   <!-- use with test1_a.xml -->
-   
-   <!-- test for the XPath 3.1 fn:abs() function -->
+   <!-- this stylesheet, tests XPath 3.1 constructor function xs:boolean(),
+        and use of logical operations on such values. -->                
 
    <xsl:output method="xml" indent="yes"/>
 
-   <xsl:template match="/elem">
-      <elem>
-         <item><xsl:value-of select="abs(5)"/></item>
-         <item><xsl:value-of select="abs(-5)"/></item>
-         <item><xsl:value-of select="abs(-2.7)"/></item>
-         <result1>
-           <xsl:for-each select="a">
-              <item><xsl:value-of select="abs(.)"/></item>
-           </xsl:for-each>
-         </result1>
-         <result2>
-	   <xsl:for-each select="a">
-	     <item><xsl:value-of select="abs()"/></item>
-	   </xsl:for-each>
-         </result2>
-         <result3>
-            <xsl:for-each select="/elem/a[abs() &gt; 7]">
-	      <item><xsl:value-of select="."/></item>
-	    </xsl:for-each>
-         </result3>
-         <extra_elem1><xsl:value-of select="a[2] &lt; 0"/></extra_elem1>
-         <extra_elem2><xsl:value-of select="a[2] &gt; 0"/></extra_elem2>
-         <extra_elem3><xsl:value-of select="abs(a[2]) &gt; 7"/></extra_elem3>
-         <extra_elem4><xsl:value-of select="abs(a[2]) &lt; 7"/></extra_elem4>
-      </elem>
+   <xsl:template match="/">
+      <xsl:variable name="bool1" select="xs:boolean(0)"/>
+      <xsl:variable name="bool2" select="xs:boolean(1)"/>
+      <result>
+         <one><xsl:value-of select="xs:boolean(0)"/></one>
+         <two><xsl:value-of select="xs:boolean(1)"/></two>
+         <three><xsl:value-of select="xs:boolean(0) = xs:boolean(0)"/></three>
+         <four><xsl:value-of select="xs:boolean(0) = xs:boolean(1)"/></four>
+         <five><xsl:value-of select="$bool1"/></five>
+	     <six><xsl:value-of select="$bool2"/></six>
+	     <seven><xsl:value-of select="$bool1 = $bool1"/></seven>
+         <eight><xsl:value-of select="$bool1 = $bool2"/></eight>
+      </result>
    </xsl:template>
    
    <!--
diff --git a/tests/fn_abs/test1.xsl b/tests/xs_constructor_functions/test3.xsl
similarity index 52%
copy from tests/fn_abs/test1.xsl
copy to tests/xs_constructor_functions/test3.xsl
index bf9719d6..304e2c23 100644
--- a/tests/fn_abs/test1.xsl
+++ b/tests/xs_constructor_functions/test3.xsl
@@ -4,37 +4,15 @@
                 
    <!-- Author: mukulg@apache.org -->
    
-   <!-- use with test1_a.xml -->
-   
-   <!-- test for the XPath 3.1 fn:abs() function -->
+   <!-- use with test1_a.xml -->             
 
    <xsl:output method="xml" indent="yes"/>
 
    <xsl:template match="/elem">
-      <elem>
-         <item><xsl:value-of select="abs(5)"/></item>
-         <item><xsl:value-of select="abs(-5)"/></item>
-         <item><xsl:value-of select="abs(-2.7)"/></item>
-         <result1>
-           <xsl:for-each select="a">
-              <item><xsl:value-of select="abs(.)"/></item>
-           </xsl:for-each>
-         </result1>
-         <result2>
-	   <xsl:for-each select="a">
-	     <item><xsl:value-of select="abs()"/></item>
-	   </xsl:for-each>
-         </result2>
-         <result3>
-            <xsl:for-each select="/elem/a[abs() &gt; 7]">
-	      <item><xsl:value-of select="."/></item>
-	    </xsl:for-each>
-         </result3>
-         <extra_elem1><xsl:value-of select="a[2] &lt; 0"/></extra_elem1>
-         <extra_elem2><xsl:value-of select="a[2] &gt; 0"/></extra_elem2>
-         <extra_elem3><xsl:value-of select="abs(a[2]) &gt; 7"/></extra_elem3>
-         <extra_elem4><xsl:value-of select="abs(a[2]) &lt; 7"/></extra_elem4>
-      </elem>
+      <result>
+         <one><xsl:value-of select="a + b = c"/></one>
+         <two><xsl:value-of select="a + b = d"/></two>
+      </result>
    </xsl:template>
    
    <!--
diff --git a/tests/fn_abs/test1.xsl b/tests/xs_constructor_functions/test4.xsl
similarity index 53%
copy from tests/fn_abs/test1.xsl
copy to tests/xs_constructor_functions/test4.xsl
index bf9719d6..53a733c2 100644
--- a/tests/fn_abs/test1.xsl
+++ b/tests/xs_constructor_functions/test4.xsl
@@ -1,40 +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"
+                exclude-result-prefixes="xs"
                 version="3.0">
                 
    <!-- Author: mukulg@apache.org -->
    
    <!-- use with test1_a.xml -->
    
-   <!-- test for the XPath 3.1 fn:abs() function -->
+   <!-- this stylesheet, does few XPath arithmetic and logical 
+        operations, involving xs:decimal types. -->             
 
    <xsl:output method="xml" indent="yes"/>
 
    <xsl:template match="/elem">
-      <elem>
-         <item><xsl:value-of select="abs(5)"/></item>
-         <item><xsl:value-of select="abs(-5)"/></item>
-         <item><xsl:value-of select="abs(-2.7)"/></item>
-         <result1>
-           <xsl:for-each select="a">
-              <item><xsl:value-of select="abs(.)"/></item>
-           </xsl:for-each>
-         </result1>
-         <result2>
-	   <xsl:for-each select="a">
-	     <item><xsl:value-of select="abs()"/></item>
-	   </xsl:for-each>
-         </result2>
-         <result3>
-            <xsl:for-each select="/elem/a[abs() &gt; 7]">
-	      <item><xsl:value-of select="."/></item>
-	    </xsl:for-each>
-         </result3>
-         <extra_elem1><xsl:value-of select="a[2] &lt; 0"/></extra_elem1>
-         <extra_elem2><xsl:value-of select="a[2] &gt; 0"/></extra_elem2>
-         <extra_elem3><xsl:value-of select="abs(a[2]) &gt; 7"/></extra_elem3>
-         <extra_elem4><xsl:value-of select="abs(a[2]) &lt; 7"/></extra_elem4>
-      </elem>
+      <result>
+         <one><xsl:value-of select="(xs:decimal(a) + xs:decimal(b)) = xs:decimal(c)"/></one>
+         <two><xsl:value-of select="(xs:decimal(a) + xs:decimal(b)) = xs:decimal(d)"/></two>
+         <three><xsl:value-of select="(xs:decimal(a) + b) = c"/></three>
+         <four><xsl:value-of select="(xs:decimal(a) + b) = d"/></four>
+      </result>
    </xsl:template>
    
    <!--
diff --git a/tests/fn_abs/test1.xsl b/tests/xs_constructor_functions/test5.xsl
similarity index 53%
copy from tests/fn_abs/test1.xsl
copy to tests/xs_constructor_functions/test5.xsl
index bf9719d6..ec6ea5c4 100644
--- a/tests/fn_abs/test1.xsl
+++ b/tests/xs_constructor_functions/test5.xsl
@@ -1,40 +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"
+                exclude-result-prefixes="xs"
                 version="3.0">
                 
    <!-- Author: mukulg@apache.org -->
    
    <!-- use with test1_a.xml -->
    
-   <!-- test for the XPath 3.1 fn:abs() function -->
+     <!-- this stylesheet, does few XPath arithmetic and logical 
+          operations, involving xs:decimal types. -->              
 
    <xsl:output method="xml" indent="yes"/>
 
    <xsl:template match="/elem">
-      <elem>
-         <item><xsl:value-of select="abs(5)"/></item>
-         <item><xsl:value-of select="abs(-5)"/></item>
-         <item><xsl:value-of select="abs(-2.7)"/></item>
-         <result1>
-           <xsl:for-each select="a">
-              <item><xsl:value-of select="abs(.)"/></item>
-           </xsl:for-each>
-         </result1>
-         <result2>
-	   <xsl:for-each select="a">
-	     <item><xsl:value-of select="abs()"/></item>
-	   </xsl:for-each>
-         </result2>
-         <result3>
-            <xsl:for-each select="/elem/a[abs() &gt; 7]">
-	      <item><xsl:value-of select="."/></item>
-	    </xsl:for-each>
-         </result3>
-         <extra_elem1><xsl:value-of select="a[2] &lt; 0"/></extra_elem1>
-         <extra_elem2><xsl:value-of select="a[2] &gt; 0"/></extra_elem2>
-         <extra_elem3><xsl:value-of select="abs(a[2]) &gt; 7"/></extra_elem3>
-         <extra_elem4><xsl:value-of select="abs(a[2]) &lt; 7"/></extra_elem4>
-      </elem>
+      <result>
+         <one><xsl:value-of select="(xs:decimal(b) - xs:decimal(a))"/></one>
+         <two><xsl:value-of select="(xs:decimal(b) - xs:decimal(a)) = 0.10"/></two>
+         <three><xsl:value-of select="(xs:decimal(b) - xs:decimal(a)) = 0.12"/></three>
+         <four><xsl:value-of select="(xs:decimal(b) - xs:decimal(a)) = (0.12 - 0.02)"/></four>
+         <five><xsl:value-of select="(xs:decimal(b) - xs:decimal(a)) + 0.12"/></five>
+      </result>
    </xsl:template>
    
    <!--
diff --git a/tests/fn_abs/test1.xsl b/tests/xs_constructor_functions/test6.xsl
similarity index 50%
copy from tests/fn_abs/test1.xsl
copy to tests/xs_constructor_functions/test6.xsl
index bf9719d6..6a3ed73c 100644
--- a/tests/fn_abs/test1.xsl
+++ b/tests/xs_constructor_functions/test6.xsl
@@ -1,40 +1,24 @@
 <?xml version="1.0"?>
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                xmlns:xs="http://www.w3.org/2001/XMLSchema"
+                exclude-result-prefixes="xs"
                 version="3.0">
                 
    <!-- Author: mukulg@apache.org -->
    
-   <!-- use with test1_a.xml -->
-   
-   <!-- test for the XPath 3.1 fn:abs() function -->
+   <!-- this stylesheet, tests XPath 3.1 constructor function xs:decimal(),
+        and use of arithmetic and logical operations on such values. -->                
 
    <xsl:output method="xml" indent="yes"/>
 
-   <xsl:template match="/elem">
-      <elem>
-         <item><xsl:value-of select="abs(5)"/></item>
-         <item><xsl:value-of select="abs(-5)"/></item>
-         <item><xsl:value-of select="abs(-2.7)"/></item>
-         <result1>
-           <xsl:for-each select="a">
-              <item><xsl:value-of select="abs(.)"/></item>
-           </xsl:for-each>
-         </result1>
-         <result2>
-	   <xsl:for-each select="a">
-	     <item><xsl:value-of select="abs()"/></item>
-	   </xsl:for-each>
-         </result2>
-         <result3>
-            <xsl:for-each select="/elem/a[abs() &gt; 7]">
-	      <item><xsl:value-of select="."/></item>
-	    </xsl:for-each>
-         </result3>
-         <extra_elem1><xsl:value-of select="a[2] &lt; 0"/></extra_elem1>
-         <extra_elem2><xsl:value-of select="a[2] &gt; 0"/></extra_elem2>
-         <extra_elem3><xsl:value-of select="abs(a[2]) &gt; 7"/></extra_elem3>
-         <extra_elem4><xsl:value-of select="abs(a[2]) &lt; 7"/></extra_elem4>
-      </elem>
+   <xsl:template match="/">
+      <xsl:variable name="decimal1" select="xs:decimal(12.23) + xs:decimal(12.2)"/>
+      <xsl:variable name="decimal2" select="xs:decimal(24.43)"/>
+      <result>
+         <one><xsl:value-of select="$decimal1"/></one>
+         <two><xsl:value-of select="$decimal2"/></two>
+         <three><xsl:value-of select="$decimal1 = $decimal2"/></three>
+      </result>
    </xsl:template>
    
    <!--


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