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/29 11:52:17 UTC

[xalan-java] branch xalan-j_xslt3.0 updated: committing implementation of xpath 3.1 component extraction functions on duration values. also committing, xpath 3.1 implementation of arithmetic 'addition' and 'subtraction' operations on duration values. committing as well, few new related working test cases for these xalanj xslt 3.0 implementation changes.

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 6cd15368 committing implementation of xpath 3.1 component extraction functions on duration values. also committing, xpath 3.1 implementation of arithmetic 'addition' and 'subtraction' operations on duration values. committing as well, few new related working test cases for these xalanj xslt 3.0 implementation changes.
     new 0b9e3ded Merge pull request #38 from mukulga/xalan-j_xslt3.0_mukul
6cd15368 is described below

commit 6cd1536862c11359f367f9b7ab55bda409ecff54
Author: Mukul Gandhi <ga...@gmail.com>
AuthorDate: Sat Jul 29 17:17:21 2023 +0530

    committing implementation of xpath 3.1 component extraction functions on duration values. also committing, xpath 3.1 implementation of arithmetic 'addition' and 'subtraction' operations on duration values. committing as well, few new related working test cases for these xalanj xslt 3.0 implementation changes.
---
 .../xalan/templates/XSConstructorFunctionUtil.java |  54 +++-
 src/org/apache/xpath/compiler/FunctionTable.java   |  58 ++++-
 src/org/apache/xpath/compiler/Keywords.java        |  50 +++-
 .../xpath/functions/FuncDaysFromDuration.java      |  71 +++++
 .../xpath/functions/FuncHoursFromDuration.java     |  71 +++++
 .../xpath/functions/FuncMinutesFromDuration.java   |  71 +++++
 .../xpath/functions/FuncMonthsFromDuration.java    |  71 +++++
 .../xpath/functions/FuncSecondsFromDuration.java   |  71 +++++
 .../xpath/functions/FuncYearsFromDuration.java     |  71 +++++
 src/org/apache/xpath/operations/Minus.java         |   6 +
 src/org/apache/xpath/operations/Plus.java          |  10 +-
 .../apache/xpath/xs/types/XSDayTimeDuration.java   |  64 +++--
 .../apache/xpath/xs/types/XSYearMonthDuration.java | 288 +++++++++++++++++++++
 .../XPathArithmeticOnDurationValuesTests.java      |  73 ++++++
 ...XsDurationComponentExtractionFunctionTests.java |  73 ++++++
 tests/org/apache/xalan/xslt3/AllXsl3Tests.java     |   5 +-
 .../xpath_duration_value_arithmetic/gold/test1.out |   4 +
 .../xpath_duration_value_arithmetic/gold/test2.out |   6 +
 tests/xpath_duration_value_arithmetic/test1.xsl    |  39 +++
 tests/xpath_duration_value_arithmetic/test1_a.xml  |   7 +
 tests/xpath_duration_value_arithmetic/test2.xsl    |  45 ++++
 .../xs_durationComponentExtraction/gold/test1.out  |  23 ++
 .../xs_durationComponentExtraction/gold/test2.out  |   6 +
 tests/xs_durationComponentExtraction/test1.xsl     |  58 +++++
 tests/xs_durationComponentExtraction/test1_a.xml   |   7 +
 tests/xs_durationComponentExtraction/test2.xsl     |  44 ++++
 26 files changed, 1303 insertions(+), 43 deletions(-)

diff --git a/src/org/apache/xalan/templates/XSConstructorFunctionUtil.java b/src/org/apache/xalan/templates/XSConstructorFunctionUtil.java
index 0b83cca4..371afabf 100644
--- a/src/org/apache/xalan/templates/XSConstructorFunctionUtil.java
+++ b/src/org/apache/xalan/templates/XSConstructorFunctionUtil.java
@@ -17,6 +17,7 @@
 package org.apache.xalan.templates;
 
 import javax.xml.XMLConstants;
+import javax.xml.transform.SourceLocator;
 import javax.xml.transform.TransformerException;
 
 import org.apache.xalan.xslt.util.XslTransformEvaluationHelper;
@@ -29,12 +30,15 @@ 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.XSDate;
+import org.apache.xpath.xs.types.XSDayTimeDuration;
 import org.apache.xpath.xs.types.XSDecimal;
 import org.apache.xpath.xs.types.XSDouble;
+import org.apache.xpath.xs.types.XSDuration;
 import org.apache.xpath.xs.types.XSFloat;
 import org.apache.xpath.xs.types.XSInt;
 import org.apache.xpath.xs.types.XSInteger;
 import org.apache.xpath.xs.types.XSLong;
+import org.apache.xpath.xs.types.XSYearMonthDuration;
 import org.xml.sax.SAXException;
 
 /**
@@ -58,6 +62,8 @@ public class XSConstructorFunctionUtil {
     public static XObject processFuncExtFunctionOrXPathOpn(XPathContext xctxt, Expression expr)
                                                                     throws TransformerException, SAXException {        
         XObject evalResult = null;
+        
+        SourceLocator srcLocator = xctxt.getSAXLocator();
 
         if (expr instanceof FuncExtFunction) {
             FuncExtFunction funcExtFunction = (FuncExtFunction)expr;
@@ -65,7 +71,7 @@ public class XSConstructorFunctionUtil {
                 // evaluate XPath 3.1 constructor function calls, corresponding to XML Schema 
                 // built-in types.
                 
-                if ((Keywords.FUNC_XS_DECIMAL).equals(funcExtFunction.getFunctionName())) {                              
+                if ((Keywords.XS_DECIMAL).equals(funcExtFunction.getFunctionName())) {                              
                     ResultSequence argSequence = new ResultSequence();
                     for (int idx = 0; idx < funcExtFunction.getArgCount(); idx++) {
                         XObject argVal = (funcExtFunction.getArg(idx)).execute(xctxt);
@@ -75,7 +81,7 @@ public class XSConstructorFunctionUtil {
                     ResultSequence rSeq = (new XSDecimal()).constructor(argSequence);
                     evalResult = rSeq.item(0);              
                 }
-                else if ((Keywords.FUNC_XS_FLOAT).equals(funcExtFunction.getFunctionName())) {                              
+                else if ((Keywords.XS_FLOAT).equals(funcExtFunction.getFunctionName())) {                              
                     ResultSequence argSequence = new ResultSequence();
                     for (int idx = 0; idx < funcExtFunction.getArgCount(); idx++) {
                         XObject argVal = (funcExtFunction.getArg(idx)).execute(xctxt);
@@ -85,7 +91,7 @@ public class XSConstructorFunctionUtil {
                     ResultSequence rSeq = (new XSFloat()).constructor(argSequence);
                     evalResult = rSeq.item(0);              
                 }
-                else if ((Keywords.FUNC_XS_DOUBLE).equals(funcExtFunction.getFunctionName())) {                              
+                else if ((Keywords.XS_DOUBLE).equals(funcExtFunction.getFunctionName())) {                              
                     ResultSequence argSequence = new ResultSequence();
                     for (int idx = 0; idx < funcExtFunction.getArgCount(); idx++) {
                         XObject argVal = (funcExtFunction.getArg(idx)).execute(xctxt);
@@ -95,7 +101,7 @@ public class XSConstructorFunctionUtil {
                     ResultSequence rSeq = (new XSDouble()).constructor(argSequence);
                     evalResult = rSeq.item(0);              
                 }
-                else if ((Keywords.FUNC_XS_INTEGER).equals(funcExtFunction.getFunctionName())) {                              
+                else if ((Keywords.XS_INTEGER).equals(funcExtFunction.getFunctionName())) {                              
                     ResultSequence argSequence = new ResultSequence();
                     for (int idx = 0; idx < funcExtFunction.getArgCount(); idx++) {
                         XObject argVal = (funcExtFunction.getArg(idx)).execute(xctxt);
@@ -105,7 +111,7 @@ public class XSConstructorFunctionUtil {
                     ResultSequence rSeq = (new XSInteger()).constructor(argSequence);
                     evalResult = rSeq.item(0);              
                 }
-                else if ((Keywords.FUNC_XS_LONG).equals(funcExtFunction.getFunctionName())) {                              
+                else if ((Keywords.XS_LONG).equals(funcExtFunction.getFunctionName())) {                              
                     ResultSequence argSequence = new ResultSequence();
                     for (int idx = 0; idx < funcExtFunction.getArgCount(); idx++) {
                         XObject argVal = (funcExtFunction.getArg(idx)).execute(xctxt);
@@ -115,7 +121,7 @@ public class XSConstructorFunctionUtil {
                     ResultSequence rSeq = (new XSLong()).constructor(argSequence);
                     evalResult = rSeq.item(0);              
                 }
-                else if ((Keywords.FUNC_XS_INT).equals(funcExtFunction.getFunctionName())) {                              
+                else if ((Keywords.XS_INT).equals(funcExtFunction.getFunctionName())) {                              
                     ResultSequence argSequence = new ResultSequence();
                     for (int idx = 0; idx < funcExtFunction.getArgCount(); idx++) {
                         XObject argVal = (funcExtFunction.getArg(idx)).execute(xctxt);
@@ -137,7 +143,7 @@ public class XSConstructorFunctionUtil {
                     ResultSequence rSeq = (new XSBoolean()).constructor(argSequence);
                     evalResult = rSeq.item(0);              
                 }
-                else if ((Keywords.FUNC_XS_DATE).equals(funcExtFunction.getFunctionName())) {                              
+                else if ((Keywords.XS_DATE).equals(funcExtFunction.getFunctionName())) {                              
                     ResultSequence argSequence = new ResultSequence();
                     for (int idx = 0; idx < funcExtFunction.getArgCount(); idx++) {
                         XObject argVal = (funcExtFunction.getArg(idx)).execute(xctxt);
@@ -147,6 +153,40 @@ public class XSConstructorFunctionUtil {
                     ResultSequence rSeq = (new XSDate()).constructor(argSequence); 
                     evalResult = rSeq.item(0);              
                 }
+                else if ((Keywords.XS_YEAR_MONTH_DURATION).equals(funcExtFunction.getFunctionName())) {                    
+                    for (int idx = 0; idx < funcExtFunction.getArgCount(); idx++) {
+                        XObject argVal = (funcExtFunction.getArg(idx)).execute(xctxt);
+                        String strVal = XslTransformEvaluationHelper.getStrVal(argVal);
+                        XSDuration xsDuration = XSYearMonthDuration.parseYearMonthDuration(strVal);
+                        if (xsDuration != null) {
+                           ResultSequence argSequence = new ResultSequence();
+                           argSequence.add(xsDuration);
+                           ResultSequence rSeq = (new XSYearMonthDuration()).constructor(argSequence); 
+                           evalResult = rSeq.item(0);
+                        }
+                        else {
+                           throw new TransformerException("FORG0001 : an invalid duration value '" + strVal + "' is "
+                                                                                               + "present in the input.", srcLocator); 
+                        }
+                    }                                  
+                }
+                else if ((Keywords.XS_DAY_TIME_DURATION).equals(funcExtFunction.getFunctionName())) {                    
+                    for (int idx = 0; idx < funcExtFunction.getArgCount(); idx++) {
+                        XObject argVal = (funcExtFunction.getArg(idx)).execute(xctxt);
+                        String strVal = XslTransformEvaluationHelper.getStrVal(argVal);
+                        XSDuration xsDuration = XSDayTimeDuration.parseDayTimeDuration(strVal);
+                        if (xsDuration != null) {
+                           ResultSequence argSequence = new ResultSequence();
+                           argSequence.add(xsDuration);
+                           ResultSequence rSeq = (new XSDayTimeDuration()).constructor(argSequence); 
+                           evalResult = rSeq.item(0);
+                        }
+                        else {
+                           throw new TransformerException("FORG0001 : an invalid duration value '" + strVal + "' is "
+                                                                                                + "present in the input.", srcLocator); 
+                        }                            
+                    }
+                }
             }
         }
         else if (expr instanceof Operation) {
diff --git a/src/org/apache/xpath/compiler/FunctionTable.java b/src/org/apache/xpath/compiler/FunctionTable.java
index dc40716e..4b7cd76e 100644
--- a/src/org/apache/xpath/compiler/FunctionTable.java
+++ b/src/org/apache/xpath/compiler/FunctionTable.java
@@ -233,6 +233,24 @@ public class FunctionTable
   
   /** The 'math:atan2()' id. */
   public static final int FUNC_MATH_ATAN2 = 69;
+  
+  /** The 'years-from-duration()' id. */
+  public static final int FUNC_YEARS_FROM_DURATION = 70;
+  
+  /** The 'months-from-duration()' id. */
+  public static final int FUNC_MONTHS_FROM_DURATION = 71;
+  
+  /** The 'days-from-duration()' id. */
+  public static final int FUNC_DAYS_FROM_DURATION = 72;
+  
+  /** The 'hours-from-duration()' id. */
+  public static final int FUNC_HOURS_FROM_DURATION = 73;
+  
+  /** The 'minutes-from-duration()' id. */
+  public static final int FUNC_MINUTES_FROM_DURATION = 74;
+  
+  /** The 'seconds-from-duration()' id. */
+  public static final int FUNC_SECONDS_FROM_DURATION = 75;
 
   // Proprietary
 
@@ -290,7 +308,7 @@ public class FunctionTable
    * Number of built in functions. Be sure to update this as
    * built-in functions are added.
    */
-  private static final int NUM_BUILT_IN_FUNCS = 70;
+  private static final int NUM_BUILT_IN_FUNCS = 76;
 
   /**
    * Number of built-in functions that may be added.
@@ -395,8 +413,8 @@ public class FunctionTable
     m_functions[FUNC_DISTINCT_VALUES] = 
       org.apache.xpath.functions.FuncDistinctValues.class;
     
-    // XPath 3.1 functions configurations for the namespace 
-    // http://www.w3.org/2005/xpath-functions/math.    
+    // XPath 3.1 functions configurations for the math functions 
+    // namespace http://www.w3.org/2005/xpath-functions/math.
     m_functions[FUNC_MATH_PI] = 
       org.apache.xpath.functions.math.FuncMathPi.class;
     m_functions[FUNC_MATH_EXP] = 
@@ -425,6 +443,21 @@ public class FunctionTable
       org.apache.xpath.functions.math.FuncMathAtan.class;
     m_functions[FUNC_MATH_ATAN2] = 
       org.apache.xpath.functions.math.FuncMathAtan2.class;
+    
+    // XPath 3.1 functions configurations for component 
+    // extraction functions on duration values.
+    m_functions[FUNC_YEARS_FROM_DURATION] = 
+      org.apache.xpath.functions.FuncYearsFromDuration.class;
+    m_functions[FUNC_MONTHS_FROM_DURATION] = 
+      org.apache.xpath.functions.FuncMonthsFromDuration.class;
+    m_functions[FUNC_DAYS_FROM_DURATION] = 
+      org.apache.xpath.functions.FuncDaysFromDuration.class;
+    m_functions[FUNC_HOURS_FROM_DURATION] = 
+      org.apache.xpath.functions.FuncHoursFromDuration.class;
+    m_functions[FUNC_MINUTES_FROM_DURATION] = 
+      org.apache.xpath.functions.FuncMinutesFromDuration.class;
+    m_functions[FUNC_SECONDS_FROM_DURATION] = 
+      org.apache.xpath.functions.FuncSecondsFromDuration.class;
   }
 
   static{
@@ -537,8 +570,8 @@ public class FunctionTable
           m_functionID.put(Keywords.FUNC_DISTINCT_VALUES,
                           new Integer(FunctionTable.FUNC_DISTINCT_VALUES));
           
-          // XPath 3.1 functions configurations for the namespace 
-          // http://www.w3.org/2005/xpath-functions/math.
+          // XPath 3.1 functions configurations for the math functions 
+          // namespace http://www.w3.org/2005/xpath-functions/math.
           m_functionID.put(Keywords.FUNC_MATH_PI,
                           new Integer(FunctionTable.FUNC_MATH_PI));
           m_functionID.put(Keywords.FUNC_MATH_EXP,
@@ -567,6 +600,21 @@ public class FunctionTable
                          new Integer(FunctionTable.FUNC_MATH_ATAN));
           m_functionID.put(Keywords.FUNC_MATH_ATAN2,
                          new Integer(FunctionTable.FUNC_MATH_ATAN2));
+          
+         // XPath 3.1 functions configurations for component 
+         // extraction functions on xdm duration values.
+         m_functionID.put(Keywords.FUNC_YEARS_FROM_DURATION,
+                         new Integer(FunctionTable.FUNC_YEARS_FROM_DURATION));
+         m_functionID.put(Keywords.FUNC_MONTHS_FROM_DURATION,
+                         new Integer(FunctionTable.FUNC_MONTHS_FROM_DURATION));
+         m_functionID.put(Keywords.FUNC_DAYS_FROM_DURATION,
+                         new Integer(FunctionTable.FUNC_DAYS_FROM_DURATION));
+         m_functionID.put(Keywords.FUNC_HOURS_FROM_DURATION,
+                         new Integer(FunctionTable.FUNC_HOURS_FROM_DURATION));
+         m_functionID.put(Keywords.FUNC_MINUTES_FROM_DURATION,
+                         new Integer(FunctionTable.FUNC_MINUTES_FROM_DURATION));
+         m_functionID.put(Keywords.FUNC_SECONDS_FROM_DURATION,
+                         new Integer(FunctionTable.FUNC_SECONDS_FROM_DURATION));
   }
   
   public FunctionTable(){
diff --git a/src/org/apache/xpath/compiler/Keywords.java b/src/org/apache/xpath/compiler/Keywords.java
index bde7edd8..6ea12a24 100644
--- a/src/org/apache/xpath/compiler/Keywords.java
+++ b/src/org/apache/xpath/compiler/Keywords.java
@@ -310,34 +310,58 @@ public class Keywords
   
   /** math:atan2 function string. */
   public static final String FUNC_MATH_ATAN2 = "atan2";
-
-  // Proprietary, built in functions
-
-  /** current function string (Proprietary). */
-  public static final String FUNC_DOCLOCATION_STRING = "document-location";
   
-  // XML Schema built-in types constructor functions, configurations
+  /** years-from-duration function string. */
+  public static final String FUNC_YEARS_FROM_DURATION = "years-from-duration";
+  
+  /** months-from-duration function string. */
+  public static final String FUNC_MONTHS_FROM_DURATION = "months-from-duration";
+  
+  /** days-from-duration function string. */
+  public static final String FUNC_DAYS_FROM_DURATION = "days-from-duration";
+  
+  /** hours-from-duration function string. */
+  public static final String FUNC_HOURS_FROM_DURATION = "hours-from-duration";
+  
+  /** minutes-from-duration function string. */
+  public static final String FUNC_MINUTES_FROM_DURATION = "minutes-from-duration";
+  
+  /** seconds-from-duration function string. */
+  public static final String FUNC_SECONDS_FROM_DURATION = "seconds-from-duration";
+  
+  // XML Schema built-in data type name keywords
   
   /** xs:decimal data type string. */
-  public static final String FUNC_XS_DECIMAL = "decimal";
+  public static final String XS_DECIMAL = "decimal";
   
   /** xs:float data type string. */
-  public static final String FUNC_XS_FLOAT = "float";
+  public static final String XS_FLOAT = "float";
   
   /** xs:double data type string. */
-  public static final String FUNC_XS_DOUBLE = "double";
+  public static final String XS_DOUBLE = "double";
   
   /** xs:integer data type string. */
-  public static final String FUNC_XS_INTEGER = "integer";
+  public static final String XS_INTEGER = "integer";
   
   /** xs:long data type string. */
-  public static final String FUNC_XS_LONG = "long";
+  public static final String XS_LONG = "long";
   
   /** xs:int data type string. */
-  public static final String FUNC_XS_INT = "int";
+  public static final String XS_INT = "int";
   
   /** xs:date data type string. */
-  public static final String FUNC_XS_DATE = "date";
+  public static final String XS_DATE = "date";
+  
+  /** xs:yearMonthDuration data type string. */
+  public static final String XS_YEAR_MONTH_DURATION = "yearMonthDuration";
+  
+  /** xs:dayTimeDuration data type string. */
+  public static final String XS_DAY_TIME_DURATION = "dayTimeDuration";
+  
+  // Proprietary, built in functions
+
+  /** current function string (Proprietary). */
+  public static final String FUNC_DOCLOCATION_STRING = "document-location";
 
   static
   {
diff --git a/src/org/apache/xpath/functions/FuncDaysFromDuration.java b/src/org/apache/xpath/functions/FuncDaysFromDuration.java
new file mode 100644
index 00000000..896f388b
--- /dev/null
+++ b/src/org/apache/xpath/functions/FuncDaysFromDuration.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.xpath.functions;
+
+import java.math.BigInteger;
+
+import javax.xml.transform.SourceLocator;
+
+import org.apache.xpath.Expression;
+import org.apache.xpath.XPathContext;
+import org.apache.xpath.objects.ResultSequence;
+import org.apache.xpath.objects.XObject;
+import org.apache.xpath.xs.types.XSDuration;
+import org.apache.xpath.xs.types.XSInteger;
+
+/**
+ * Implementation of the days-from-duration() function.
+ * 
+ * @author Mukul Gandhi <mu...@apache.org>
+ * 
+ * @xsl.usage advanced
+ */
+public class FuncDaysFromDuration extends FunctionOneArg {
+
+    private static final long serialVersionUID = -8471054241151786884L;
+
+    public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
+    {
+        XObject result = null;
+        
+        SourceLocator srcLocator = xctxt.getSAXLocator();
+        
+        try {
+           Expression arg0 = getArg0();
+           
+           if (arg0 == null || isArgCountErr()) {
+              ResultSequence resultSeq = new ResultSequence();
+              return resultSeq;
+           }
+            
+           XSDuration xsDuration = (XSDuration)(((FuncExtFunction)arg0).execute(xctxt));
+            
+           int days = xsDuration.days();
+           if (xsDuration.negative()) {
+              days = days * -1;
+           }
+            
+           result = new XSInteger(BigInteger.valueOf(days));
+        }
+        catch (Exception ex) {
+           throw new javax.xml.transform.TransformerException(ex.getMessage(), srcLocator); 
+        }
+        
+        return result;
+    }
+
+}
diff --git a/src/org/apache/xpath/functions/FuncHoursFromDuration.java b/src/org/apache/xpath/functions/FuncHoursFromDuration.java
new file mode 100644
index 00000000..d09c06d4
--- /dev/null
+++ b/src/org/apache/xpath/functions/FuncHoursFromDuration.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.xpath.functions;
+
+import java.math.BigInteger;
+
+import javax.xml.transform.SourceLocator;
+
+import org.apache.xpath.Expression;
+import org.apache.xpath.XPathContext;
+import org.apache.xpath.objects.ResultSequence;
+import org.apache.xpath.objects.XObject;
+import org.apache.xpath.xs.types.XSDuration;
+import org.apache.xpath.xs.types.XSInteger;
+
+/**
+ * Implementation of the hours-from-duration() function.
+ * 
+ * @author Mukul Gandhi <mu...@apache.org>
+ * 
+ * @xsl.usage advanced
+ */
+public class FuncHoursFromDuration extends FunctionOneArg {
+
+    private static final long serialVersionUID = -7046073260941724285L;
+
+    public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
+    {
+        XObject result = null;
+        
+        SourceLocator srcLocator = xctxt.getSAXLocator();
+        
+        try {
+           Expression arg0 = getArg0();
+           
+           if (arg0 == null || isArgCountErr()) {
+              ResultSequence resultSeq = new ResultSequence();
+              return resultSeq;
+           }
+            
+           XSDuration xsDuration = (XSDuration)(((FuncExtFunction)arg0).execute(xctxt));
+            
+           int hours = xsDuration.hours();
+           if (xsDuration.negative()) {
+              hours = hours * -1;
+           }
+            
+           result = new XSInteger(BigInteger.valueOf(hours));
+        }
+        catch (Exception ex) {
+           throw new javax.xml.transform.TransformerException(ex.getMessage(), srcLocator); 
+        }
+        
+        return result;
+    }
+
+}
diff --git a/src/org/apache/xpath/functions/FuncMinutesFromDuration.java b/src/org/apache/xpath/functions/FuncMinutesFromDuration.java
new file mode 100644
index 00000000..fa543429
--- /dev/null
+++ b/src/org/apache/xpath/functions/FuncMinutesFromDuration.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.xpath.functions;
+
+import java.math.BigInteger;
+
+import javax.xml.transform.SourceLocator;
+
+import org.apache.xpath.Expression;
+import org.apache.xpath.XPathContext;
+import org.apache.xpath.objects.ResultSequence;
+import org.apache.xpath.objects.XObject;
+import org.apache.xpath.xs.types.XSDuration;
+import org.apache.xpath.xs.types.XSInteger;
+
+/**
+ * Implementation of the minutes-from-duration() function.
+ * 
+ * @author Mukul Gandhi <mu...@apache.org>
+ * 
+ * @xsl.usage advanced
+ */
+public class FuncMinutesFromDuration extends FunctionOneArg {
+
+    private static final long serialVersionUID = -1670079254820160771L;
+
+    public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
+    {
+        XObject result = null;
+        
+        SourceLocator srcLocator = xctxt.getSAXLocator();
+        
+        try {
+           Expression arg0 = getArg0();
+           
+           if (arg0 == null || isArgCountErr()) {
+              ResultSequence resultSeq = new ResultSequence();
+              return resultSeq;
+           }
+            
+           XSDuration xsDuration = (XSDuration)(((FuncExtFunction)arg0).execute(xctxt));
+            
+           int minutes = xsDuration.minutes();
+           if (xsDuration.negative()) {
+              minutes = minutes * -1;
+           }
+            
+           result = new XSInteger(BigInteger.valueOf(minutes));
+        }
+        catch (Exception ex) {
+           throw new javax.xml.transform.TransformerException(ex.getMessage(), srcLocator); 
+        }
+        
+        return result;
+    }
+
+}
diff --git a/src/org/apache/xpath/functions/FuncMonthsFromDuration.java b/src/org/apache/xpath/functions/FuncMonthsFromDuration.java
new file mode 100644
index 00000000..a4076d0b
--- /dev/null
+++ b/src/org/apache/xpath/functions/FuncMonthsFromDuration.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.xpath.functions;
+
+import java.math.BigInteger;
+
+import javax.xml.transform.SourceLocator;
+
+import org.apache.xpath.Expression;
+import org.apache.xpath.XPathContext;
+import org.apache.xpath.objects.ResultSequence;
+import org.apache.xpath.objects.XObject;
+import org.apache.xpath.xs.types.XSDuration;
+import org.apache.xpath.xs.types.XSInteger;
+
+/**
+ * Implementation of the months-from-duration() function.
+ * 
+ * @author Mukul Gandhi <mu...@apache.org>
+ * 
+ * @xsl.usage advanced
+ */
+public class FuncMonthsFromDuration extends FunctionOneArg {
+
+    private static final long serialVersionUID = -2529130205133544977L;
+
+    public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
+    {
+        XObject result = null;
+        
+        SourceLocator srcLocator = xctxt.getSAXLocator();
+        
+        try {
+           Expression arg0 = getArg0();
+           
+           if (arg0 == null || isArgCountErr()) {
+              ResultSequence resultSeq = new ResultSequence();
+              return resultSeq;
+           }
+            
+           XSDuration xsDuration = (XSDuration)(((FuncExtFunction)arg0).execute(xctxt));
+            
+           int month = xsDuration.month();
+           if (xsDuration.negative()) {
+              month = month * -1;
+           }
+            
+           result = new XSInteger(BigInteger.valueOf(month));
+        }
+        catch (Exception ex) {
+           throw new javax.xml.transform.TransformerException(ex.getMessage(), srcLocator); 
+        }
+        
+        return result;
+    }
+
+}
diff --git a/src/org/apache/xpath/functions/FuncSecondsFromDuration.java b/src/org/apache/xpath/functions/FuncSecondsFromDuration.java
new file mode 100644
index 00000000..4c7d87a0
--- /dev/null
+++ b/src/org/apache/xpath/functions/FuncSecondsFromDuration.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.xpath.functions;
+
+import java.math.BigDecimal;
+
+import javax.xml.transform.SourceLocator;
+
+import org.apache.xpath.Expression;
+import org.apache.xpath.XPathContext;
+import org.apache.xpath.objects.ResultSequence;
+import org.apache.xpath.objects.XObject;
+import org.apache.xpath.xs.types.XSDecimal;
+import org.apache.xpath.xs.types.XSDuration;
+
+/**
+ * Implementation of the seconds-from-duration() function.
+ * 
+ * @author Mukul Gandhi <mu...@apache.org>
+ * 
+ * @xsl.usage advanced
+ */
+public class FuncSecondsFromDuration extends FunctionOneArg {
+
+    private static final long serialVersionUID = -5785715296430278331L;
+
+    public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
+    {
+        XObject result = null;
+        
+        SourceLocator srcLocator = xctxt.getSAXLocator();
+        
+        try {
+           Expression arg0 = getArg0();
+           
+           if (arg0 == null || isArgCountErr()) {
+              ResultSequence resultSeq = new ResultSequence();
+              return resultSeq;
+           }
+            
+           XSDuration xsDuration = (XSDuration)(((FuncExtFunction)arg0).execute(xctxt));
+            
+           double seconds = xsDuration.seconds();
+           if (xsDuration.negative()) {
+              seconds = seconds * -1;
+           }
+            
+           result = new XSDecimal(new BigDecimal(seconds));
+        }
+        catch (Exception ex) {
+           throw new javax.xml.transform.TransformerException(ex.getMessage(), srcLocator); 
+        }
+        
+        return result;
+    }
+
+}
diff --git a/src/org/apache/xpath/functions/FuncYearsFromDuration.java b/src/org/apache/xpath/functions/FuncYearsFromDuration.java
new file mode 100644
index 00000000..85a3c7e6
--- /dev/null
+++ b/src/org/apache/xpath/functions/FuncYearsFromDuration.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.xpath.functions;
+
+import java.math.BigInteger;
+
+import javax.xml.transform.SourceLocator;
+
+import org.apache.xpath.Expression;
+import org.apache.xpath.XPathContext;
+import org.apache.xpath.objects.ResultSequence;
+import org.apache.xpath.objects.XObject;
+import org.apache.xpath.xs.types.XSDuration;
+import org.apache.xpath.xs.types.XSInteger;
+
+/**
+ * Implementation of the years-from-duration() function.
+ * 
+ * @author Mukul Gandhi <mu...@apache.org>
+ * 
+ * @xsl.usage advanced
+ */
+public class FuncYearsFromDuration extends FunctionOneArg {
+
+    private static final long serialVersionUID = -5098972397509827951L;
+
+    public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
+    {
+        XObject result = null;
+        
+        SourceLocator srcLocator = xctxt.getSAXLocator();
+        
+        try {
+           Expression arg0 = getArg0();
+           
+           if (arg0 == null || isArgCountErr()) {
+              ResultSequence resultSeq = new ResultSequence();
+              return resultSeq;
+           }
+            
+           XSDuration xsDuration = (XSDuration)(((FuncExtFunction)arg0).execute(xctxt));
+            
+           int year = xsDuration.year();
+           if (xsDuration.negative()) {
+              year = year * -1;
+           }
+            
+           result = new XSInteger(BigInteger.valueOf(year));
+        }
+        catch (Exception ex) {
+           throw new javax.xml.transform.TransformerException(ex.getMessage(), srcLocator); 
+        }
+        
+        return result;
+    }
+
+}
diff --git a/src/org/apache/xpath/operations/Minus.java b/src/org/apache/xpath/operations/Minus.java
index e4f015ca..0d39e911 100644
--- a/src/org/apache/xpath/operations/Minus.java
+++ b/src/org/apache/xpath/operations/Minus.java
@@ -30,6 +30,7 @@ import org.apache.xpath.xs.types.XSFloat;
 import org.apache.xpath.xs.types.XSInt;
 import org.apache.xpath.xs.types.XSInteger;
 import org.apache.xpath.xs.types.XSLong;
+import org.apache.xpath.xs.types.XSYearMonthDuration;
 
 /**
  * The binary '-' operation expression executer.
@@ -75,6 +76,11 @@ public class Minus extends Operation
           return new XSInt(bigIntLeft.subtract(bigIntRight));    
       }
       
+      if ((left instanceof XSYearMonthDuration) && 
+                                           (right instanceof XSYearMonthDuration)) {
+          return ((XSYearMonthDuration)left).subtract((XSYearMonthDuration)right);  
+      }
+      
       double leftArg = 0.0;
       double rightArg = 0.0;
       
diff --git a/src/org/apache/xpath/operations/Plus.java b/src/org/apache/xpath/operations/Plus.java
index d2475512..9038e960 100644
--- a/src/org/apache/xpath/operations/Plus.java
+++ b/src/org/apache/xpath/operations/Plus.java
@@ -30,6 +30,7 @@ import org.apache.xpath.xs.types.XSFloat;
 import org.apache.xpath.xs.types.XSInt;
 import org.apache.xpath.xs.types.XSInteger;
 import org.apache.xpath.xs.types.XSLong;
+import org.apache.xpath.xs.types.XSYearMonthDuration;
 
 /**
  * The '+' operation expression executer.
@@ -58,7 +59,7 @@ public class Plus extends Operation
          BigInteger bigintRight = ((XSInteger)right).intValue();
          
          return new XSInteger(bigintLeft.add(bigintRight));    
-      }
+      }      
       
       if ((left instanceof XSLong) && (right instanceof XSLong)) {
           BigInteger bigintLeft = ((XSLong)left).intValue();
@@ -67,7 +68,7 @@ public class Plus extends Operation
           // its possible that, result after addition is, not within value space of xs:long.
           // handle this error. revisit
           return new XSLong(bigintLeft.add(bigintRight));    
-      }
+      }      
       
       if ((left instanceof XSInt) && (right instanceof XSInt)) {
           BigInteger bigintLeft = ((XSInt)left).intValue();
@@ -78,6 +79,11 @@ public class Plus extends Operation
           return new XSInt(bigintLeft.add(bigintRight));    
       }
       
+      if ((left instanceof XSYearMonthDuration) && 
+                                         (right instanceof XSYearMonthDuration)) {
+          return ((XSYearMonthDuration)left).add((XSYearMonthDuration)right);  
+      }
+      
       double leftArg = 0.0;
       double rightArg = 0.0;
       
diff --git a/src/org/apache/xpath/xs/types/XSDayTimeDuration.java b/src/org/apache/xpath/xs/types/XSDayTimeDuration.java
index 72b85b75..074768b3 100644
--- a/src/org/apache/xpath/xs/types/XSDayTimeDuration.java
+++ b/src/org/apache/xpath/xs/types/XSDayTimeDuration.java
@@ -69,9 +69,25 @@ public class XSDayTimeDuration extends XSDuration {
 		super(0, 0, 0, 0, 0, 0.0, false);
 	}
 
+	/**
+	 * A method to construct an xdm sequence comprising a
+	 * xs:dayTimeDuration value, given input data as argument
+	 * to this method.
+	 */
 	public ResultSequence constructor(ResultSequence arg) {
-	    // TO DO
-	    return null;	
+        ResultSequence resultSeq = new ResultSequence();
+        
+        if (arg.size() == 0) {
+           return resultSeq;     
+        }
+        
+        XSAnyType xsAnyType = (XSAnyType)arg.item(0);
+        
+        XSDuration xsDuration = castToDayTimeDuration(xsAnyType);
+        
+        resultSeq.add(xsDuration);
+
+        return resultSeq;	
 	}
 
 	
@@ -79,11 +95,12 @@ public class XSDayTimeDuration extends XSDuration {
 	 * Creates a new XSDuration object, by parsing the supplied String
 	 * representation of XSDuration.
 	 * 
-	 * @param str      String representation of XSDuration
+	 * @param    strVal      String representation of XSDuration value
 	 * 
-	 * @return         new XSDuration object, representing the supplied string
+	 * @return               new XSDuration object, representing the 
+	 *                       supplied string.
 	 */
-	public static XSDuration parseDTDuration(String str) {
+	public static XSDuration parseDayTimeDuration(String strVal) {
 		boolean negative = false;
 		int days = 0;
 		int hours = 0;
@@ -93,19 +110,19 @@ public class XSDayTimeDuration extends XSDuration {
 		String pstr = null;
 		String tstr = null;
 
-		if (str.startsWith("-P")) {
+		if (strVal.startsWith("-P")) {
 			negative = true;
-			pstr = str.substring(2, str.length());
-		} else if (str.startsWith("P")) {
+			pstr = strVal.substring(2, strVal.length());
+		} else if (strVal.startsWith("P")) {
 			negative = false;
-			pstr = str.substring(1, str.length());
+			pstr = strVal.substring(1, strVal.length());
 		} else {
 			return null;
 		}
 
 		try {
 			int index = pstr.indexOf('D');
-			boolean did_something = false;
+			boolean actionStatus = false;
 
 			if (index == -1) {
 				if (pstr.startsWith("T")) {
@@ -125,7 +142,7 @@ public class XSDayTimeDuration extends XSDuration {
 						return null;
 					}
 					tstr = "";
-					did_something = true;
+					actionStatus = true;
 				}
 			}
 
@@ -134,7 +151,7 @@ public class XSDayTimeDuration extends XSDuration {
 				String digit = tstr.substring(0, index);
 				hours = Integer.parseInt(digit);
 				tstr = tstr.substring(index + 1, tstr.length());
-				did_something = true;
+				actionStatus = true;
 			}
 
 			index = tstr.indexOf('M');
@@ -142,7 +159,7 @@ public class XSDayTimeDuration extends XSDuration {
 				String digit = tstr.substring(0, index);
 				minutes = Integer.parseInt(digit);
 				tstr = tstr.substring(index + 1, tstr.length());
-				did_something = true;
+				actionStatus = true;
 			}
 
 			index = tstr.indexOf('S');
@@ -150,9 +167,9 @@ public class XSDayTimeDuration extends XSDuration {
 				String digit = tstr.substring(0, index);
 				seconds = Double.parseDouble(digit);
 				tstr = tstr.substring(index + 1, tstr.length());
-				did_something = true;
+				actionStatus = true;
 			}
-			if (did_something) {
+			if (actionStatus) {
 				if (tstr.length() != 0) {
 					return null;
 				}
@@ -185,4 +202,21 @@ public class XSDayTimeDuration extends XSDuration {
 		return XS_DAY_TIME_DURATION;
 	}
 	
+	/**
+     * Do a data type cast, of a XSAnyType value to an XSDuration
+     * value. 
+     */
+	private XSDuration castToDayTimeDuration(XSAnyType xsAnyType) {
+        
+	    if (xsAnyType instanceof XSDuration) {
+            XSDuration xsDuration = (XSDuration) xsAnyType;
+            
+            return new XSDayTimeDuration(xsDuration.days(), xsDuration.hours(), 
+                                         xsDuration.minutes(), xsDuration.seconds(), 
+                                         xsDuration.negative());
+        }
+        
+        return parseDayTimeDuration(xsAnyType.stringValue());
+    }
+	
 }
diff --git a/src/org/apache/xpath/xs/types/XSYearMonthDuration.java b/src/org/apache/xpath/xs/types/XSYearMonthDuration.java
new file mode 100644
index 00000000..3541ae9f
--- /dev/null
+++ b/src/org/apache/xpath/xs/types/XSYearMonthDuration.java
@@ -0,0 +1,288 @@
+/*
+ * 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.
+ */
+/*
+ * $Id$
+ */
+package org.apache.xpath.xs.types;
+
+import org.apache.xpath.objects.ResultSequence;
+
+/**
+ * An XML Schema data type representation, of the xs:yearMonthDuration 
+ * data type.
+ * 
+ * @author Mukul Gandhi <mu...@apache.org>
+ * 
+ * @xsl.usage advanced
+ */
+public class XSYearMonthDuration extends XSDuration {
+
+    private static final long serialVersionUID = 4448560721093003316L;
+    
+    private static final String XS_YEAR_MONTH_DURATION = "xs:yearMonthDuration";
+
+    /**
+     * Initializes this object, using the supplied parameters.
+     * 
+     * @param year        number of years in this duration of time
+     * @param month       number of months in this duration of time
+     * @param negative   'true' if this duration of time represents a backwards
+     *                    passage through time. 'false' otherwise.
+     */
+    public XSYearMonthDuration(int year, int month, boolean negative) {
+        super(year, month, 0, 0, 0, 0, negative);
+    }
+    
+    /**
+     * Initializes this object, to the supplied number of months.
+     * 
+     * @param months  number of months in the duration of time
+     */
+    public XSYearMonthDuration(int months) {
+        this(0, Math.abs(months), months < 0);
+    }
+
+    /**
+     * Initializes this object, to a duration with value zero 
+     * (i.e, zero years, and zero months).
+     */
+    public XSYearMonthDuration() {
+        this(0, 0, false);
+    }
+    
+    /**
+     * Creates a new XSYearMonthDuration object, by parsing the supplied
+     * string representing the duration value.
+     * 
+     * @param   strVal   String representation of the duration value
+     * @return           new XSYearMonthDuration object, representing the
+     *                   duration of time supplied.
+     */
+    public static XSDuration parseYearMonthDuration(String strVal) {
+        boolean negative = false;
+        
+        int year = 0;
+        int month = 0;
+
+        int moveAheadIndication = 0;
+
+        String digits = "";
+        
+        for (int idx = 0; idx < strVal.length(); idx++) {
+            char charVal = strVal.charAt(idx);
+
+            switch (moveAheadIndication) {
+            case 0:
+                if (charVal == '-') {
+                   negative = true;
+                   moveAheadIndication = 4;
+                } else if (charVal == 'P') {
+                   moveAheadIndication = 5;
+                }
+                else {
+                   return null;
+                }
+                break;
+            case 4:
+                if (charVal == 'P') {
+                   moveAheadIndication = 5;
+                }
+                else {
+                   return null;
+                }
+                break;
+            case 5:
+                if ('0' <= charVal && charVal <= '9') {
+                   digits += charVal;
+                }
+                else if (charVal == 'Y') {
+                    if (digits.length() == 0) {
+                       return null;
+                    }
+                    year = Integer.parseInt(digits);
+                    digits = "";
+                    moveAheadIndication = 6;
+                } else if (charVal == 'M') {
+                    if (digits.length() == 0) {
+                       return null;
+                    }
+                    month = Integer.parseInt(digits);
+                    moveAheadIndication = 7;
+                } else {
+                    return null;
+                }
+                break;
+            case 6:
+               if ('0' <= charVal && charVal <= '9') {
+                  digits += charVal;
+               }
+               else if (charVal == 'M') {
+                  if (digits.length() == 0) {
+                     return null;
+                  }
+                  month = Integer.parseInt(digits);
+                  moveAheadIndication = 7;
+                } else {
+                    return null;
+                }
+                break;
+            case 7:
+               return null;
+            default:
+               return null;
+            }
+        }
+
+        return new XSYearMonthDuration(year, month, negative);
+    }
+
+    /**
+     * A method to construct an xdm sequence comprising a
+     * xs:yearMonthDuration value, given input data as argument
+     * to this method.
+     */
+	public ResultSequence constructor(ResultSequence arg) {
+        ResultSequence resultSeq = new ResultSequence();
+        
+        if (arg.size() == 0) {
+           return resultSeq;     
+        }
+        
+        XSAnyType xsAnyType = (XSAnyType)arg.item(0);
+        
+        XSDuration xsDuration = castToYearMonthDuration(xsAnyType);
+        
+        resultSeq.add(xsDuration);
+
+        return resultSeq;	
+	}
+
+	/**
+	 * Get the data type's name.
+	 * 
+	 * @return   the string value 'yearMonthDuration', which is this
+	 *           data type's name.
+	 */
+	public String typeName() {
+		return "yearMonthDuration";
+	}
+	
+	/**
+     * Check whether, this duration value represents a backward passage
+     * through time.
+     * 
+     * @return 'true' if this duration value represents a backward passage
+     *         through time. 'false' otherwise.
+     */
+    public boolean negative() {
+        return _negative;
+    }
+	
+	/**
+     * Get a string representation, of the duration value represented
+     * by this object.
+     * 
+     * @return   String representation, of the duration value represented
+     *           by this object. 
+     */
+    public String stringValue() {
+        String strVal = "";
+
+        if (negative()) {
+           strVal += "-";
+        }
+
+        strVal += "P";
+
+        int years = year();
+        if (years != 0) {
+           strVal += years + "Y";
+        }
+
+        int months = month();
+        if (months == 0) {
+           if (years == 0) {
+              strVal += months + "M";
+           }
+        } else {
+           strVal += months + "M";
+        }
+
+        return strVal;
+    }
+
+	/**
+	 * Get the data type's name.
+	 * 
+	 * @return  the string value 'xs:yearMonthDuration'
+	 */
+	public String stringType() {
+	   return XS_YEAR_MONTH_DURATION;
+	}
+	
+	/**
+     * Get the duration of time as the number of months, equivalent
+     * to this duration object.
+     * 
+     * @return   number of months, equivalent to the duration of time
+     *           represented by this object.
+     */
+    public int monthValue() {
+       int retVal = (year() * 12) + month();
+
+       if (negative())
+          retVal *= -1;
+
+       return retVal;
+    }
+    
+    /**
+     * Add two XSYearMonthDuration values, and return the result
+     * as an XSYearMonthDuration value.
+     */
+    public XSYearMonthDuration add(XSYearMonthDuration arg) {
+       XSYearMonthDuration result = new XSYearMonthDuration(monthValue() + 
+                                                                arg.monthValue());       
+       return result; 
+    }
+    
+    /**
+     * Subtract one XSYearMonthDuration value from another XSYearMonthDuration value,
+     * and return the result as an XSYearMonthDuration value.
+     */
+    public XSYearMonthDuration subtract(XSYearMonthDuration arg) {
+       XSYearMonthDuration result = new XSYearMonthDuration(monthValue() - 
+                                                                arg.monthValue());       
+       return result; 
+    }
+    
+    /**
+     * Do a data type cast, of a XSAnyType value to an XSDuration
+     * value. 
+     */
+    private XSDuration castToYearMonthDuration(XSAnyType xsAnyType) {
+        if (xsAnyType instanceof XSDuration) {
+           XSDuration xsDuration = (XSDuration) xsAnyType;
+           
+           return new XSYearMonthDuration(xsDuration.year(), xsDuration.month(), 
+                                          xsDuration.negative());
+        }
+        
+        return parseYearMonthDuration(xsAnyType.stringValue());
+    }
+	
+}
diff --git a/tests/org/apache/xalan/xpath3/XPathArithmeticOnDurationValuesTests.java b/tests/org/apache/xalan/xpath3/XPathArithmeticOnDurationValuesTests.java
new file mode 100644
index 00000000..be77fdde
--- /dev/null
+++ b/tests/org/apache/xalan/xpath3/XPathArithmeticOnDurationValuesTests.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.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;
+
+/**
+ * XPath 3.1 test cases, to test arithmetic operations on
+ * XML Schema duration typed values.
+ * 
+ * @author Mukul Gandhi <mu...@apache.org>
+ * 
+ * @xsl.usage advanced
+ */
+public class XPathArithmeticOnDurationValuesTests extends XslTransformTestsUtil {        
+    
+    private static final String XSL_TRANSFORM_INPUT_DIRPATH = XSLConstants.XSL_TRANSFORM_INPUT_DIRPATH_PREFIX + 
+                                                                                                   "xpath_duration_value_arithmetic/";
+    
+    private static final String XSL_TRANSFORM_GOLD_DIRPATH = XSLConstants.XSL_TRANSFORM_GOLD_DIRPATH_PREFIX + 
+                                                                                                   "xpath_duration_value_arithmetic/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 xslArithmeticOnDurationValuesTest1() {
+        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 xslArithmeticOnDurationValuesTest2() {
+        String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test1_a.xml"; 
+        String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test2.xsl";
+        
+        String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test2.out";                
+        
+        runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+    }
+
+}
diff --git a/tests/org/apache/xalan/xpath3/XsDurationComponentExtractionFunctionTests.java b/tests/org/apache/xalan/xpath3/XsDurationComponentExtractionFunctionTests.java
new file mode 100644
index 00000000..dca83d79
--- /dev/null
+++ b/tests/org/apache/xalan/xpath3/XsDurationComponentExtractionFunctionTests.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.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;
+
+/**
+ * XPath 3.1 test cases, to test component extraction functions 
+ * on XML Schema duration typed values.
+ * 
+ * @author Mukul Gandhi <mu...@apache.org>
+ * 
+ * @xsl.usage advanced
+ */
+public class XsDurationComponentExtractionFunctionTests extends XslTransformTestsUtil {        
+    
+    private static final String XSL_TRANSFORM_INPUT_DIRPATH = XSLConstants.XSL_TRANSFORM_INPUT_DIRPATH_PREFIX + 
+                                                                                                     "xs_durationComponentExtraction/";
+    
+    private static final String XSL_TRANSFORM_GOLD_DIRPATH = XSLConstants.XSL_TRANSFORM_GOLD_DIRPATH_PREFIX + 
+                                                                                                     "xs_durationComponentExtraction/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 xslComponentExtractionFunctionTest1() {
+        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 xslComponentExtractionFunctionTest2() {
+        String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test1_a.xml"; 
+        String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test2.xsl";
+        
+        String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test2.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 8587cbe0..23f54c7d 100644
--- a/tests/org/apache/xalan/xslt3/AllXsl3Tests.java
+++ b/tests/org/apache/xalan/xslt3/AllXsl3Tests.java
@@ -17,6 +17,7 @@
 package org.apache.xalan.xslt3;
 
 import org.apache.xalan.xpath3.BuiltinFunctionsNamespceTests;
+import org.apache.xalan.xpath3.XsDurationComponentExtractionFunctionTests;
 import org.apache.xalan.xpath3.DynamicFunctionCallTests;
 import org.apache.xalan.xpath3.FnAbsTests;
 import org.apache.xalan.xpath3.FnDistinctValuesTests;
@@ -38,6 +39,7 @@ import org.apache.xalan.xpath3.StringConcatExprTests;
 import org.apache.xalan.xpath3.StringTests;
 import org.apache.xalan.xpath3.TrignometricAndExponentialFunctionTests;
 import org.apache.xalan.xpath3.ValueComparisonTests;
+import org.apache.xalan.xpath3.XPathArithmeticOnDurationValuesTests;
 import org.apache.xalan.xpath3.XsConstructorFunctionTests;
 import org.junit.runner.RunWith;
 import org.junit.runners.Suite;
@@ -66,7 +68,8 @@ import org.junit.runners.Suite.SuiteClasses;
                 FnFilterTests.class, DynamicFunctionCallTests.class, IfExprTests.class, 
                 ForExprTests.class, LetExprTests.class, FnDistinctValuesTests.class,
                 TrignometricAndExponentialFunctionTests.class, BuiltinFunctionsNamespceTests.class,
-                SequenceConstructorTests.class, StringConcatExprTests.class })
+                SequenceConstructorTests.class, StringConcatExprTests.class, 
+                XsDurationComponentExtractionFunctionTests.class, XPathArithmeticOnDurationValuesTests.class })
 public class AllXsl3Tests {
 
 }
diff --git a/tests/xpath_duration_value_arithmetic/gold/test1.out b/tests/xpath_duration_value_arithmetic/gold/test1.out
new file mode 100644
index 00000000..bdea4c3e
--- /dev/null
+++ b/tests/xpath_duration_value_arithmetic/gold/test1.out
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?><result>
+  <one>P6Y2M</one>
+  <two>-P4M</two>
+</result>
diff --git a/tests/xpath_duration_value_arithmetic/gold/test2.out b/tests/xpath_duration_value_arithmetic/gold/test2.out
new file mode 100644
index 00000000..e84d0aa3
--- /dev/null
+++ b/tests/xpath_duration_value_arithmetic/gold/test2.out
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?><result>
+  <one>P6Y2M</one>
+  <two>-P4M</two>
+  <three>P6Y2M</three>
+  <four>-P4M</four>
+</result>
diff --git a/tests/xpath_duration_value_arithmetic/test1.xsl b/tests/xpath_duration_value_arithmetic/test1.xsl
new file mode 100644
index 00000000..32ba215f
--- /dev/null
+++ b/tests/xpath_duration_value_arithmetic/test1.xsl
@@ -0,0 +1,39 @@
+<?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 -->
+   
+   <!-- This XSLT stylesheet, tests XPath 3.1 arithmetic on
+        XML Schema duration typed values. -->                
+
+   <xsl:output method="xml" indent="yes"/>
+      
+   <xsl:template match="/">
+      <result>
+         <one><xsl:value-of select="xs:yearMonthDuration('P2Y11M') + xs:yearMonthDuration('P3Y3M')"/></one>
+         <two><xsl:value-of select="xs:yearMonthDuration('P2Y11M') - xs:yearMonthDuration('P3Y3M')"/></two>
+      </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/xpath_duration_value_arithmetic/test1_a.xml b/tests/xpath_duration_value_arithmetic/test1_a.xml
new file mode 100644
index 00000000..a16f9eb6
--- /dev/null
+++ b/tests/xpath_duration_value_arithmetic/test1_a.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<temp>
+  <val1>P2Y11M</val1>
+  <val2>P3Y3M</val2>
+  <a val="P2Y11M"/>
+  <b val="P3Y3M"/>
+</temp>
\ No newline at end of file
diff --git a/tests/xpath_duration_value_arithmetic/test2.xsl b/tests/xpath_duration_value_arithmetic/test2.xsl
new file mode 100644
index 00000000..0aa00b70
--- /dev/null
+++ b/tests/xpath_duration_value_arithmetic/test2.xsl
@@ -0,0 +1,45 @@
+<?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 -->
+   
+   <!-- This XSLT stylesheet, tests XPath 3.1 arithmetic
+        on XML Schema duration typed values, by fetching
+        the input values from an XML external source 
+        document. -->                
+
+   <xsl:output method="xml" indent="yes"/>
+      
+   <xsl:template match="/temp">
+      <result>
+         <one><xsl:value-of select="xs:yearMonthDuration(val1) + xs:yearMonthDuration(val2)"/></one>
+         <two><xsl:value-of select="xs:yearMonthDuration(val1) - xs:yearMonthDuration(val2)"/></two>
+         <three><xsl:value-of select="xs:yearMonthDuration(a/@val) + xs:yearMonthDuration(b/@val)"/></three>
+         <four><xsl:value-of select="xs:yearMonthDuration(a/@val) - xs:yearMonthDuration(b/@val)"/></four>
+      </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/xs_durationComponentExtraction/gold/test1.out b/tests/xs_durationComponentExtraction/gold/test1.out
new file mode 100644
index 00000000..7426369c
--- /dev/null
+++ b/tests/xs_durationComponentExtraction/gold/test1.out
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?><result>
+  <one>21</one>
+  <two>-1</two>
+  <snip/>
+  <three>3</three>
+  <four>-6</four>
+  <five>0</five>
+  <snip/>
+  <six>3</six>
+  <seven>5</seven>
+  <eight>0</eight>
+  <snip/>
+  <nine>10</nine>
+  <ten>12</ten>
+  <eleven>3</eleven>
+  <twelve>-10</twelve>
+  <snip/>
+  <thirteen>0</thirteen>
+  <fourteen>-30</fourteen>
+  <snip/>
+  <fifteen>12.5</fifteen>
+  <sixteen>-16</sixteen>
+</result>
diff --git a/tests/xs_durationComponentExtraction/gold/test2.out b/tests/xs_durationComponentExtraction/gold/test2.out
new file mode 100644
index 00000000..62078211
--- /dev/null
+++ b/tests/xs_durationComponentExtraction/gold/test2.out
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?><result>
+  <one>21</one>
+  <two>-1</two>
+  <three>21</three>
+  <four>-1</four>
+</result>
diff --git a/tests/xs_durationComponentExtraction/test1.xsl b/tests/xs_durationComponentExtraction/test1.xsl
new file mode 100644
index 00000000..2112a489
--- /dev/null
+++ b/tests/xs_durationComponentExtraction/test1.xsl
@@ -0,0 +1,58 @@
+<?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 -->
+   
+   <!-- This XSLT stylesheet, tests XPath 3.1 duration values,
+        component extraction functions. -->                 
+
+   <xsl:output method="xml" indent="yes"/>
+      
+   <xsl:template match="/">
+      <result>
+         <one><xsl:value-of select="years-from-duration(xs:yearMonthDuration('P20Y15M'))"/></one>
+         <two><xsl:value-of select="years-from-duration(xs:yearMonthDuration('-P15M'))"/></two>
+         <snip/>
+         <three><xsl:value-of select="months-from-duration(xs:yearMonthDuration('P20Y15M'))"/></three>
+         <four><xsl:value-of select="months-from-duration(xs:yearMonthDuration('-P20Y18M'))"/></four>
+         <five><xsl:value-of select="months-from-duration(xs:dayTimeDuration('-P2DT15H0M0S'))"/></five>
+         <snip/>
+         <six><xsl:value-of select="days-from-duration(xs:dayTimeDuration('P3DT10H'))"/></six>
+	     <seven><xsl:value-of select="days-from-duration(xs:dayTimeDuration('P3DT55H'))"/></seven>
+         <eight><xsl:value-of select="days-from-duration(xs:yearMonthDuration('P3Y5M'))"/></eight>
+         <snip/>
+         <nine><xsl:value-of select="hours-from-duration(xs:dayTimeDuration('P3DT10H'))"/></nine>
+         <ten><xsl:value-of select="hours-from-duration(xs:dayTimeDuration('P3DT12H32M12S'))"/></ten>
+         <eleven><xsl:value-of select="hours-from-duration(xs:dayTimeDuration('PT123H'))"/></eleven>
+         <twelve><xsl:value-of select="hours-from-duration(xs:dayTimeDuration('-P3DT10H'))"/></twelve>
+         <snip/>
+         <thirteen><xsl:value-of select="minutes-from-duration(xs:dayTimeDuration('P3DT10H'))"/></thirteen>
+         <fourteen><xsl:value-of select="minutes-from-duration(xs:dayTimeDuration('-P5DT12H30M'))"/></fourteen>
+         <snip/>
+         <fifteen><xsl:value-of select="seconds-from-duration(xs:dayTimeDuration('P3DT10H12.5S'))"/></fifteen>
+         <sixteen><xsl:value-of select="seconds-from-duration(xs:dayTimeDuration('-PT256S'))"/></sixteen>
+      </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/xs_durationComponentExtraction/test1_a.xml b/tests/xs_durationComponentExtraction/test1_a.xml
new file mode 100644
index 00000000..37e49d3e
--- /dev/null
+++ b/tests/xs_durationComponentExtraction/test1_a.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<temp>
+  <val1>P20Y15M</val1>
+  <val2>-P15M</val2>
+  <a val="P20Y15M"/>
+  <b val="-P15M"/>
+</temp>
\ No newline at end of file
diff --git a/tests/xs_durationComponentExtraction/test2.xsl b/tests/xs_durationComponentExtraction/test2.xsl
new file mode 100644
index 00000000..5c69e258
--- /dev/null
+++ b/tests/xs_durationComponentExtraction/test2.xsl
@@ -0,0 +1,44 @@
+<?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 -->
+   
+   <!-- This XSLT stylesheet, tests XPath 3.1 duration values,
+        component extraction functions, by fetching the input
+        values from an XML external source document. -->                 
+
+   <xsl:output method="xml" indent="yes"/>
+      
+   <xsl:template match="/temp">
+      <result>
+         <one><xsl:value-of select="years-from-duration(xs:yearMonthDuration(val1))"/></one>
+         <two><xsl:value-of select="years-from-duration(xs:yearMonthDuration(val2))"/></two>
+         <three><xsl:value-of select="years-from-duration(xs:yearMonthDuration(a/@val))"/></three>
+         <four><xsl:value-of select="years-from-duration(xs:yearMonthDuration(b/@val))"/></four>
+      </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


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