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 2026/01/22 17:19:24 UTC

(xalan-java) branch xalan-j_xslt3.0_mvn updated: committing xalan xslt 3.0 development code implementation improvements

This is an automated email from the ASF dual-hosted git repository.

mukulg pushed a commit to branch xalan-j_xslt3.0_mvn
in repository https://gitbox.apache.org/repos/asf/xalan-java.git


The following commit(s) were added to refs/heads/xalan-j_xslt3.0_mvn by this push:
     new cc119d92b committing xalan xslt 3.0 development code implementation improvements
cc119d92b is described below

commit cc119d92b3dae4ba6c3202110a16290ef60fd0ee
Author: Mukul Gandhi <ga...@gmail.com>
AuthorDate: Thu Jan 22 22:48:55 2026 +0530

    committing xalan xslt 3.0 development code implementation improvements
---
 .../xpath/functions/datetime/FuncDateTime.java       | 14 +++++++++++---
 src/main/java/org/apache/xpath/operations/Div.java   | 20 ++++++++++++++++++--
 .../w3c/xslt3/result/type/_date-test-set_result.xml  |  8 ++++----
 .../result/w3c_xslt3_testsuite_xalan-j_result.xml    |  4 ++--
 4 files changed, 35 insertions(+), 11 deletions(-)

diff --git a/src/main/java/org/apache/xpath/functions/datetime/FuncDateTime.java b/src/main/java/org/apache/xpath/functions/datetime/FuncDateTime.java
index 9f65a7ab6..d9b8017a0 100644
--- a/src/main/java/org/apache/xpath/functions/datetime/FuncDateTime.java
+++ b/src/main/java/org/apache/xpath/functions/datetime/FuncDateTime.java
@@ -32,7 +32,7 @@ import xml.xpath31.processor.types.XSDuration;
 import xml.xpath31.processor.types.XSTime;
 
 /**
- * Implementation of fn:dateTime function.
+ * Implementation of XPath 3.1 function fn:dateTime.
  * 
  * @author Mukul Gandhi <mu...@apache.org>
  * 
@@ -108,8 +108,16 @@ public class FuncDateTime extends Function2Args
 	  cal.set(dateVal.year(), dateVal.month() - 1, dateVal.day());
 	  cal.set(Calendar.HOUR_OF_DAY, timeVal.hour());
 	  cal.set(Calendar.MINUTE, timeVal.minute());
-	  cal.set(Calendar.SECOND, (new Double(Math.floor(timeVal.second())).intValue()));
-	  cal.set(Calendar.MILLISECOND, 0);
+	  
+	  double secsValue = timeVal.second();
+	  int secs = (int)secsValue;
+	  int deltaMilliSecs = 0;
+	  if (secsValue > secs) {
+	     deltaMilliSecs = (int)((secsValue - secs) * 1000);
+	  }
+	  
+	  cal.set(Calendar.SECOND, secs);
+	  cal.set(Calendar.MILLISECOND, deltaMilliSecs);
 	  
 	  result = new XSDateTime(cal, resultTimeZone);
 	  
diff --git a/src/main/java/org/apache/xpath/operations/Div.java b/src/main/java/org/apache/xpath/operations/Div.java
index f5b83aad9..f100eb140 100644
--- a/src/main/java/org/apache/xpath/operations/Div.java
+++ b/src/main/java/org/apache/xpath/operations/Div.java
@@ -377,8 +377,24 @@ public class Div extends XPathArithmeticOp
      }
      else if (left instanceof XSYearMonthDuration) {
          try {
-            java.lang.String rStrVal = XslTransformEvaluationHelper.getStrVal(right);
-            result = ((XSYearMonthDuration)left).div(new XSDouble(rStrVal));
+        	 if (right instanceof XSYearMonthDuration) {
+        		 XSYearMonthDuration lValue = (XSYearMonthDuration)left;        		         		 
+        		 XSYearMonthDuration rValue = (XSYearMonthDuration)right;
+        		 
+        		 boolean isNegativeValue = ((lValue.negative() && !rValue.negative()) || (!lValue.negative() && rValue.negative()));
+        		 
+        		 int lMonthValue = (lValue.year() * 12) + lValue.month();
+        		 int rMonthValue = (rValue.year() * 12) + rValue.month();        		 
+        		 double rDouble = (lMonthValue / (double)rMonthValue);
+        		 
+        		 rDouble = (isNegativeValue ? -1 * rDouble : rDouble); 
+        		 
+        		 result = new XSDecimal(java.lang.String.valueOf(rDouble));
+        	 }
+        	 else {
+        		 java.lang.String rStrVal = XslTransformEvaluationHelper.getStrVal(right);
+        		 result = ((XSYearMonthDuration)left).div(new XSDouble(rStrVal));
+        	 }
          }
          catch (XPathException ex) {
             throw new javax.xml.transform.TransformerException(ex.getMessage());  
diff --git a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/type/_date-test-set_result.xml b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/type/_date-test-set_result.xml
index ca62437ee..89a48e711 100644
--- a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/type/_date-test-set_result.xml
+++ b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/type/_date-test-set_result.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2026-01-22T11:39:37Z" fail="49" name="date" pass="85" run="134" skipped="4" statusUnknown="0">
+<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2026-01-22T17:11:41Z" fail="46" name="date" pass="88" run="134" skipped="4" statusUnknown="0">
    <testResult status="pass" testName="date-001"/>
    <testResult status="pass" testName="date-002"/>
    <testResult status="pass" testName="date-003"/>
@@ -88,15 +88,15 @@
    <testResult status="pass" testName="date-076a"/>
    <testResult status="pass" testName="date-077"/>
    <testResult status="pass" testName="date-078"/>
-   <testResult status="fail" testName="date-079"/>
+   <testResult status="pass" testName="date-079"/>
    <testResult reason="Xalan configured" status="skipped" testName="date-080"/>
    <testResult reason="Xalan configured" status="skipped" testName="date-081"/>
    <testResult reason="Xalan configured" status="skipped" testName="date-082"/>
    <testResult reason="Xalan configured" status="skipped" testName="date-083"/>
-   <testResult status="fail" testName="date-084"/>
+   <testResult status="pass" testName="date-084"/>
    <testResult status="pass" testName="date-085"/>
    <testResult status="pass" testName="date-086"/>
-   <testResult status="fail" testName="date-087"/>
+   <testResult status="pass" testName="date-087"/>
    <testResult status="pass" testName="date-088"/>
    <testResult status="pass" testName="date-089"/>
    <testResult status="fail" testName="date-090">
diff --git a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/w3c_xslt3_testsuite_xalan-j_result.xml b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/w3c_xslt3_testsuite_xalan-j_result.xml
index fffa330a9..5726907dd 100644
--- a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/w3c_xslt3_testsuite_xalan-j_result.xml
+++ b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/w3c_xslt3_testsuite_xalan-j_result.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<testResult dateTime="2026-01-22T11:40:37Z" desc="W3C XSLT 3.0 test suite results" fail="1343" pass="3317" run="4666" skipped="598" success="71.09%" xslt_processor="Apache Xalan XSLT 3.0 development code">
+<testResult dateTime="2026-01-22T17:12:47Z" desc="W3C XSLT 3.0 test suite results" fail="1340" pass="3320" run="4666" skipped="598" success="71.15%" xslt_processor="Apache Xalan XSLT 3.0 development code">
   <attr>
     <as fail="29" pass="82" run="111" skipped="93" success="73.87%"/>
     <avt fail="1" pass="33" run="34" skipped="1" success="97.06%"/>
@@ -65,7 +65,7 @@
   </misc>
   <type>
     <boolean fail="1" pass="104" run="105" skipped="7" success="99.05%"/>
-    <date fail="49" pass="85" run="134" skipped="4" success="63.43%"/>
+    <date fail="46" pass="88" run="134" skipped="4" success="65.67%"/>
     <namespace fail="83" pass="138" run="221" skipped="3" success="62.44%"/>
     <node fail="1" pass="31" run="32" skipped="0" success="96.88%"/>
     <string fail="6" pass="128" run="134" skipped="2" success="95.52%"/>


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