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/03/10 16:01:51 UTC

(xalan-java) branch xalan-j_xslt3.0_mvn updated: committing xalan-j xslt 3.0 implementation improvements for xsl:for-each->xsl:sort instruction

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 8a169ca1b committing xalan-j xslt 3.0 implementation improvements for xsl:for-each->xsl:sort instruction
8a169ca1b is described below

commit 8a169ca1b6a1860a973def32ae425cde169c88b8
Author: Mukul Gandhi <ga...@gmail.com>
AuthorDate: Tue Mar 10 21:31:20 2026 +0530

    committing xalan-j xslt 3.0 implementation improvements for xsl:for-each->xsl:sort instruction
---
 BUILDING.txt                                       |  9 +++----
 .../org/apache/xalan/templates/ElemForEach.java    | 28 +++++++++++++++-------
 .../w3c/xslt3/result/attr/_avt-test-set_result.xml |  4 ++--
 .../result/w3c_xslt3_testsuite_xalan-j_result.xml  |  4 ++--
 4 files changed, 28 insertions(+), 17 deletions(-)

diff --git a/BUILDING.txt b/BUILDING.txt
index 3010c298a..33c2810ec 100644
--- a/BUILDING.txt
+++ b/BUILDING.txt
@@ -34,12 +34,13 @@ are collectively named as XSL (Extensible Stylesheet Language). There are variou
 src code and document locations, where the name XSL is been used to refer to XSLT 3.0 and XPath 3.1.
 
 Xalan-J implementation is primarily dependent, on Xerces-J src code that provides XML parse and XML Schema
-implementation support. Xalan-J XSLT 3.0 implementation is currently in development stage, and 
-Xalan team is trying to release Xalan-J XSLT 3.0 implementation as a formal software alpha release 
+implementation support. Xalan-J XSLT 3.0 implementation is presently in development stage, and 
+Xalan team hopes to release Xalan-J XSLT 3.0 implementation as a formal software alpha release 
 (ref, https://en.wikipedia.org/wiki/Software_release_life_cycle).
 
-Xalan-J XSLT 3.0 development code, currently uses Xerces-J build jar named as xercesImpl-2.12.3_dev1.jar
-that is produced from Xerces-J's latest unreleased code from its 'main' branch. 
+Xalan-J XSLT 3.0 development code, presently uses Xerces-J build jar named as xercesImpl-2.12.3_dev2.jar 
+(the name of this jar file may change in future, and proper alpha, beta or other names for this jar shall 
+be used) that is produced from Xerces-J's latest unreleased code from its 'main' branch. 
 
 Following are the steps, to run Xalan-J's XSLT 3.0 and XPath 3.1 conformance tests and produce 
 XSLT 3.0 build jar file (containing Xalan-J's XSLT 3.0 and XPath 3.1 run-time processors):  
diff --git a/src/main/java/org/apache/xalan/templates/ElemForEach.java b/src/main/java/org/apache/xalan/templates/ElemForEach.java
index a0218dcf5..f58552279 100644
--- a/src/main/java/org/apache/xalan/templates/ElemForEach.java
+++ b/src/main/java/org/apache/xalan/templates/ElemForEach.java
@@ -754,10 +754,18 @@ public class ElemForEach extends ElemTemplateElement implements ExpressionOwner
     	    ElemSort elemSort = (ElemSort)m_sortElems.get(idx);    	    
     	    AVT langAvt = elemSort.getLang();
     	    
-    	    String collation = null;
+    	    String collationValueStr = null;
     	    AVT collationAvt = elemSort.getCollation();
-    	    if (collationAvt != null) {
-    	       collation = collationAvt.evaluate(xctxt, contextNode, xctxt.getNamespaceContext());
+    	    
+    	    if ((collationAvt != null) && (langAvt != null)) {    	    	
+    	       String langStr = langAvt.evaluate(xctxt, contextNode, xctxt.getNamespaceContext());    	    	
+    	       collationValueStr = collationAvt.evaluate(xctxt, contextNode, xctxt.getNamespaceContext());
+    	       
+    	       if (XPathCollationSupport.UNICODE_CODEPOINT_COLLATION_URI.equals(collationValueStr) && "en".equals(langStr)) {
+    	          langAvt = null;
+    	       }
+    	       
+    	       collationValueStr = collationAvt.evaluate(xctxt, contextNode, xctxt.getNamespaceContext());    	           	       
     	    }
     	    
     	    if (langAvt != null) {    	    	    	           	       
@@ -765,12 +773,12 @@ public class ElemForEach extends ElemTemplateElement implements ExpressionOwner
     	       if (!"en".equals(langStr)) {
     	    	  bool1 = true;
     	       }
-    	       else if ((collation != null) && XPathCollationSupport.UNICODE_CODEPOINT_COLLATION_URI.equals(collation)) {
+    	       else if ((collationValueStr != null) && XPathCollationSupport.UNICODE_CODEPOINT_COLLATION_URI.equals(collationValueStr)) {
     	    	  bool1 = true; 
     	       }
     	    }
     	    
-    	    if (!bool1 && (collation != null)) {
+    	    if (!bool1 && (collationValueStr != null)) {
     	       bool1 = true;
     	    }
     	}
@@ -1050,6 +1058,8 @@ public class ElemForEach extends ElemTemplateElement implements ExpressionOwner
 	   
 	   SourceLocator srcLocator = xctxt.getSAXLocator();
 	   
+	   final int sourceNode = xctxt.getCurrentNode();
+	   
 	   if (evalResult instanceof ResultSequence) {
 		   ResultSequence resultSeq = (ResultSequence)evalResult;
 		   xdmItemList = resultSeq.getResultSequenceItems();   
@@ -1123,7 +1133,7 @@ public class ElemForEach extends ElemTemplateElement implements ExpressionOwner
 					   String sortOrderStr = null;
 					   AVT sortOrderAvt = elemSort.getOrder();
 					   if (sortOrderAvt != null) {
-						   sortOrderStr = sortOrderAvt.evaluate(xctxt, DTM.NULL, xctxt.getNamespaceContext());
+						   sortOrderStr = sortOrderAvt.evaluate(xctxt, sourceNode, xctxt.getNamespaceContext());
 					   }
 
 					   // This can be absent, or specified as "upper-first" | "lower-first".
@@ -1131,7 +1141,7 @@ public class ElemForEach extends ElemTemplateElement implements ExpressionOwner
 					   String caseOrderStr = null;		  
 					   AVT caseOrderAvt = elemSort.getCaseOrder();
 					   if (caseOrderAvt != null) {
-						   caseOrderStr = caseOrderAvt.evaluate(xctxt, DTM.NULL, xctxt.getNamespaceContext()); 
+						   caseOrderStr = caseOrderAvt.evaluate(xctxt, sourceNode, xctxt.getNamespaceContext()); 
 					   }			   			   			   
 
 					   // This can be absent (which will be default "text"), or specified as 
@@ -1139,13 +1149,13 @@ public class ElemForEach extends ElemTemplateElement implements ExpressionOwner
 					   String dataTypeStr = null;          
 					   AVT dataTypeAvt = elemSort.getDataType();
 					   if (dataTypeAvt != null) {
-						   dataTypeStr = dataTypeAvt.evaluate(xctxt, DTM.NULL, xctxt.getNamespaceContext()); 
+						   dataTypeStr = dataTypeAvt.evaluate(xctxt, sourceNode, xctxt.getNamespaceContext()); 
 					   }
 
 					   String langStr = null;
 					   AVT langAvt = elemSort.getLang();
 					   if (langAvt != null) {
-						   langStr = langAvt.evaluate(xctxt, DTM.NULL, xctxt.getNamespaceContext());  
+						   langStr = langAvt.evaluate(xctxt, sourceNode, xctxt.getNamespaceContext());  
 					   }					   
 
 					   if ((dataTypeStr != null) && !("text".equals(dataTypeStr) || "number".equals(dataTypeStr))) {							  
diff --git a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/attr/_avt-test-set_result.xml b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/attr/_avt-test-set_result.xml
index 0c4d7c101..6473e4155 100644
--- a/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/attr/_avt-test-set_result.xml
+++ b/src/test/java/org/apache/xalan/tests/w3c/xslt3/result/attr/_avt-test-set_result.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2026-02-20T15:32:54Z" fail="1" name="avt" pass="33" run="34" skipped="1" statusUnknown="0">
+<?xml version="1.0" encoding="UTF-8"?><testrun dateTime="2026-03-10T15:30:10Z" fail="0" name="avt" pass="34" run="34" skipped="1" statusUnknown="0">
    <testResult status="pass" testName="avt-0101"/>
    <testResult status="pass" testName="avt-0201"/>
    <testResult status="pass" testName="avt-0202"/>
@@ -10,7 +10,7 @@
    <testResult status="pass" testName="avt-0601"/>
    <testResult status="pass" testName="avt-0701"/>
    <testResult status="pass" testName="avt-0801"/>
-   <testResult status="fail" testName="avt-0901"/>
+   <testResult status="pass" testName="avt-0901"/>
    <testResult status="pass" testName="avt-1001"/>
    <testResult status="pass" testName="avt-1101"/>
    <testResult status="pass" testName="avt-1201"/>
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 be93a447a..d3e41bda6 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,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<testResult dateTime="2026-02-28T09:15:50Z" desc="W3C XSLT 3.0 test suite results" fail="1282" pass="3448" run="4771" skipped="608" success="72.27%" xslt_processor="Apache Xalan XSLT 3.0 development code">
+<testResult dateTime="2026-03-10T15:30:50Z" desc="W3C XSLT 3.0 test suite results" fail="1281" pass="3449" run="4771" skipped="608" success="72.29%" xslt_processor="Apache Xalan XSLT 3.0 development code">
   <attr>
     <as fail="16" pass="89" run="106" skipped="98" success="83.96%"/>
-    <avt fail="1" pass="33" run="34" skipped="1" success="97.06%"/>
+    <avt fail="0" pass="34" run="34" skipped="1" success="100.0%"/>
     <disable-output-escaping fail="5" pass="22" run="27" skipped="5" success="81.48%"/>
     <expand-text fail="7" pass="52" run="59" skipped="3" success="88.14%"/>
     <match fail="81" pass="101" run="182" skipped="112" success="55.49%"/>


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