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 2024/10/31 15:06:41 UTC

(xalan-java) branch xalan-j_xslt3.0 updated: committing implementation of xpath 3.1 document-node() sequence type, along with few related working test cases

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

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


The following commit(s) were added to refs/heads/xalan-j_xslt3.0 by this push:
     new 3c68a4c1d committing implementation of xpath 3.1 document-node() sequence type, along with few related working test cases
3c68a4c1d is described below

commit 3c68a4c1d2719cb536fee12d84195d84b8c1c356
Author: Mukul Gandhi <ga...@gmail.com>
AuthorDate: Thu Oct 31 20:36:30 2024 +0530

    committing implementation of xpath 3.1 document-node() sequence type, along with few related working test cases
---
 src/org/apache/xpath/compiler/XPathParser.java     | 11 +++++
 .../xpath/composite/SequenceTypeSupport.java       | 40 ++++++++++++----
 .../apache/xalan/tests/xslt3/XslFunctionTests.java | 50 +++++++++++++++++++
 tests/xsl_function/gold/test19.out                 |  4 ++
 tests/xsl_function/gold/test20.out                 |  4 ++
 tests/xsl_function/gold/test21.out                 |  1 +
 tests/xsl_function/gold/test22.out                 |  1 +
 tests/xsl_function/gold/test23.out                 |  1 +
 tests/xsl_function/info1.json                      | 14 ++++++
 tests/xsl_function/test19.xsl                      | 52 ++++++++++++++++++++
 tests/xsl_function/test2.xml                       | 14 ++++++
 tests/xsl_function/test20.xsl                      | 56 ++++++++++++++++++++++
 tests/xsl_function/test21.xsl                      | 53 ++++++++++++++++++++
 tests/xsl_function/test22.xsl                      | 55 +++++++++++++++++++++
 tests/xsl_function/test23.xsl                      | 53 ++++++++++++++++++++
 tests/xsl_function/test3.xml                       | 14 ++++++
 16 files changed, 415 insertions(+), 8 deletions(-)

diff --git a/src/org/apache/xpath/compiler/XPathParser.java b/src/org/apache/xpath/compiler/XPathParser.java
index bdf32b2ae..d7d3dbf0b 100644
--- a/src/org/apache/xpath/compiler/XPathParser.java
+++ b/src/org/apache/xpath/compiler/XPathParser.java
@@ -5307,6 +5307,17 @@ public class XPathParser
            xpathSequenceTypeExpr.setSequenceTypeKindTest(sequenceTypeKindTest);
            consumeExpected(')');
        }
+       else if (tokenIs("document-node")) {
+    	   sequenceTypeKindTest = new SequenceTypeKindTest();
+           sequenceTypeKindTest.setKindVal(SequenceTypeSupport.DOCUMENT_KIND);          
+           nextToken();
+           consumeExpected('(');
+           consumeExpected(')');
+           xpathSequenceTypeExpr.setSequenceTypeKindTest(sequenceTypeKindTest);
+           if (m_token != null) {
+              setSequenceTypeOccurenceIndicator(xpathSequenceTypeExpr, isXPathInlineFunctionParse);  
+           }
+       }
        else {
     	   // Check possibility of user-defined schema type specified within the sequence type expression
     	   parseSequenceTypeExprWithUserDefinedType(xpathSequenceTypeExpr, null);                                                                                    
diff --git a/src/org/apache/xpath/composite/SequenceTypeSupport.java b/src/org/apache/xpath/composite/SequenceTypeSupport.java
index 2ebf29b56..971b7927d 100644
--- a/src/org/apache/xpath/composite/SequenceTypeSupport.java
+++ b/src/org/apache/xpath/composite/SequenceTypeSupport.java
@@ -207,6 +207,8 @@ public class SequenceTypeSupport {
     
     public static int SCHEMA_ATTRIBUTE_KIND = 108;
     
+    public static int DOCUMENT_KIND = 109;
+    
     /**
      * Sequence type occurrence indicator values, for Xalan-J 
      * implementation.
@@ -491,6 +493,19 @@ public class SequenceTypeSupport {
 	            		  return result;
 	            	   }
 	            	}
+	            	else if (sequenceTypeKindTest.getKindVal() == DOCUMENT_KIND) {
+	            	   if (srcValue instanceof XNodeSet) {
+	            		  XNodeSet nodeSet1 = (XNodeSet)srcValue;
+	            		  DTMManager dtmMgr = nodeSet1.getDTMManager();
+	            		  int nodeHandle = nodeSet1.nextNode();
+	            		  DTM dtm = dtmMgr.getDTM(nodeHandle);
+	            		  if (dtm.getNodeType(nodeHandle) == DTM.DOCUMENT_NODE) {
+	            			 result = srcValue;
+	            			 
+	            			 return result;
+	            		  }
+	            	   }
+	            	}	            	
             	}
             	else if (seqExpectedTypeData.getBuiltInSequenceType() == SequenceTypeSupport.XS_ANY_ATOMIC_TYPE) {
             		if (srcValue instanceof ResultSequence) {
@@ -500,7 +515,8 @@ public class SequenceTypeSupport {
             					                   (itemTypeOccurenceIndicator == OccurrenceIndicator.ZERO_OR_MANY) ||
             					                   (itemTypeOccurenceIndicator == OccurrenceIndicator.ONE_OR_MANY))) {
             			   if (rSeq.item(0) instanceof XSAnyAtomicType) {
-            			      result = rSeq.item(0);            			      
+            			      result = rSeq.item(0);
+            			      
             			      return result;
             			   }
             			}
@@ -515,6 +531,7 @@ public class SequenceTypeSupport {
             			    }
             			    if (isSeqAnyAtomicType) {
             			       result = rSeq;
+            			       
             			       return result;
             			    }
             			}
@@ -522,10 +539,11 @@ public class SequenceTypeSupport {
             					 (itemTypeOccurenceIndicator == OccurrenceIndicator.ZERO_OR_MANY)) {
             				// an input sequence is empty
             				result = rSeq;
+            				
          			        return result;
             			}
             		}            		
-            	}
+            	}            	
             }
             
             if (srcValue instanceof XString) {
@@ -1527,7 +1545,8 @@ public class SequenceTypeSupport {
                         }
                         
                         if (nodeSetLen == 1) {
-                           result = nodeSetItem;                           
+                           result = nodeSetItem;
+                           
                            return result;
                         }
                      }
@@ -1575,7 +1594,8 @@ public class SequenceTypeSupport {
                         }
                         
                         if (nodeSetLen == 1) {
-                           result = nodeSetItem;                            
+                           result = nodeSetItem;
+                           
                            return result;
                         }
                      }
@@ -1590,7 +1610,8 @@ public class SequenceTypeSupport {
                         }
                         
                         if (nodeSetLen == 1) {
-                           result = nodeSetItem;                            
+                           result = nodeSetItem;
+                           
                            return result;
                         }
                      }
@@ -1605,7 +1626,8 @@ public class SequenceTypeSupport {
                          }
                          
                          if (nodeSetLen == 1) {
-                            result = nodeSetItem;                             
+                            result = nodeSetItem;
+                            
                             return result;
                          }
                      }
@@ -1613,7 +1635,8 @@ public class SequenceTypeSupport {
                          convertedResultSeq.add(nodeSetItem);
                          
                          if (nodeSetLen == 1) {
-                            result = nodeSetItem;                             
+                            result = nodeSetItem;
+                            
                             return result;
                          }
                      }
@@ -1630,7 +1653,8 @@ public class SequenceTypeSupport {
                      XObject xObject = castXdmValueToAnotherType(new XSString(nodeStrVal), sequenceTypeNewXPathExprStr, 
                                                                                                                     seqExpectedTypeDataInp, xctxt);                     
                      if (nodeSetLen == 1) {
-                         result = xObject;                             
+                         result = xObject;
+                         
                          return result;
                      }
                      else {
diff --git a/tests/org/apache/xalan/tests/xslt3/XslFunctionTests.java b/tests/org/apache/xalan/tests/xslt3/XslFunctionTests.java
index 534aa6b64..5967ff4ea 100644
--- a/tests/org/apache/xalan/tests/xslt3/XslFunctionTests.java
+++ b/tests/org/apache/xalan/tests/xslt3/XslFunctionTests.java
@@ -228,5 +228,55 @@ public class XslFunctionTests extends XSLTransformTestsUtil {
         
         runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
     }
+    
+    @Test
+    public void xslFunctionTest19() {
+        String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test19.xsl"; 
+        String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test19.xsl";
+        
+        String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test19.out";                
+        
+        runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+    }
+    
+    @Test
+    public void xslFunctionTest20() {
+        String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test2.xml"; 
+        String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test20.xsl";
+        
+        String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test20.out";                
+        
+        runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+    }
+    
+    @Test
+    public void xslFunctionTest21() {
+        String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test21.xsl"; 
+        String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test21.xsl";
+        
+        String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test21.out";                
+        
+        runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+    }
+    
+    @Test
+    public void xslFunctionTest22() {
+        String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test3.xml"; 
+        String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test22.xsl";
+        
+        String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test22.out";                
+        
+        runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+    }
+    
+    @Test
+    public void xslFunctionTest23() {
+        String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test23.xsl"; 
+        String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test23.xsl";
+        
+        String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test23.out";                
+        
+        runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+    }
 
 }
diff --git a/tests/xsl_function/gold/test19.out b/tests/xsl_function/gold/test19.out
new file mode 100644
index 000000000..b94cfba59
--- /dev/null
+++ b/tests/xsl_function/gold/test19.out
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?><divPoint>
+  <x>3.6</x>
+  <y>-2.4</y>
+</divPoint>
diff --git a/tests/xsl_function/gold/test20.out b/tests/xsl_function/gold/test20.out
new file mode 100644
index 000000000..b94cfba59
--- /dev/null
+++ b/tests/xsl_function/gold/test20.out
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?><divPoint>
+  <x>3.6</x>
+  <y>-2.4</y>
+</divPoint>
diff --git a/tests/xsl_function/gold/test21.out b/tests/xsl_function/gold/test21.out
new file mode 100644
index 000000000..0271e7f55
--- /dev/null
+++ b/tests/xsl_function/gold/test21.out
@@ -0,0 +1 @@
+<?xml version="1.0" encoding="UTF-8"?><area>35.5</area>
diff --git a/tests/xsl_function/gold/test22.out b/tests/xsl_function/gold/test22.out
new file mode 100644
index 000000000..0271e7f55
--- /dev/null
+++ b/tests/xsl_function/gold/test22.out
@@ -0,0 +1 @@
+<?xml version="1.0" encoding="UTF-8"?><area>35.5</area>
diff --git a/tests/xsl_function/gold/test23.out b/tests/xsl_function/gold/test23.out
new file mode 100644
index 000000000..0271e7f55
--- /dev/null
+++ b/tests/xsl_function/gold/test23.out
@@ -0,0 +1 @@
+<?xml version="1.0" encoding="UTF-8"?><area>35.5</area>
diff --git a/tests/xsl_function/info1.json b/tests/xsl_function/info1.json
new file mode 100644
index 000000000..2303cc7b2
--- /dev/null
+++ b/tests/xsl_function/info1.json
@@ -0,0 +1,14 @@
+[
+   {
+      "x" : 1,
+  	  "y" : 3
+   },
+   {
+	  "x" : 2,
+	  "y" : -5
+   },
+   {
+	  "x" : -8,
+	  "y" : 4
+   }
+]
diff --git a/tests/xsl_function/test19.xsl b/tests/xsl_function/test19.xsl
new file mode 100644
index 000000000..6f3f71379
--- /dev/null
+++ b/tests/xsl_function/test19.xsl
@@ -0,0 +1,52 @@
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"			    
+			    xmlns:xs="http://www.w3.org/2001/XMLSchema"
+				xmlns:fn0="http://fn0"
+			    exclude-result-prefixes="xs fn0" version="3.0">
+			    
+  <!-- Author: mukulg@apache.org -->
+    
+  <!-- An XSL stylesheet test case, to test an XSL element xsl:function. -->			    
+  
+  <xsl:output method="xml" indent="yes"/>
+  
+  <xsl:template match="/">
+     <xsl:copy-of select="fn0:getDivPoint((6,-4),(0,0),(2,3))"/>
+  </xsl:template>
+  
+  <!-- An XSL function definition, to find division point of 
+       a line-segment in the ratio m1:m2. -->
+  <xsl:function name="fn0:getDivPoint" as="element(divPoint)">
+     <xsl:param name="p1" as="xs:integer*"/>
+	 <xsl:param name="p2" as="xs:integer*"/>
+	 <xsl:param name="ratio" as="xs:positiveInteger*"/>
+	 <xsl:variable name="x1" select="$p1[1]" as="xs:integer"/>
+	 <xsl:variable name="y1" select="$p1[2]" as="xs:integer"/>
+	 <xsl:variable name="x2" select="$p2[1]" as="xs:integer"/>
+	 <xsl:variable name="y2" select="$p2[2]" as="xs:integer"/>
+	 <xsl:variable name="m1" select="$ratio[1]" as="xs:positiveInteger"/>
+	 <xsl:variable name="m2" select="$ratio[2]" as="xs:positiveInteger"/>
+	 <divPoint>
+	   <x><xsl:value-of select="($m2*$x1 + $m1*$x2) div ($m1 + $m2)"/></x>
+	   <y><xsl:value-of select="($m2*$y1 + $m1*$y2) div ($m1 + $m2)"/></y>
+	 </divPoint>	 
+  </xsl:function>
+  
+  <!--
+      * 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>
diff --git a/tests/xsl_function/test2.xml b/tests/xsl_function/test2.xml
new file mode 100644
index 000000000..056407e11
--- /dev/null
+++ b/tests/xsl_function/test2.xml
@@ -0,0 +1,14 @@
+<info>
+  <point>
+    <x>6</x>
+	<y>-4</y>
+  </point>
+  <point>
+    <x>0</x>
+	<y>0</y>
+  </point>
+  <ratio>
+    <m1>2</m1>
+	<m2>3</m2>
+  </ratio>
+</info>
diff --git a/tests/xsl_function/test20.xsl b/tests/xsl_function/test20.xsl
new file mode 100644
index 000000000..fba0ddcf2
--- /dev/null
+++ b/tests/xsl_function/test20.xsl
@@ -0,0 +1,56 @@
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"			    
+			    xmlns:xs="http://www.w3.org/2001/XMLSchema"
+				xmlns:fn0="http://fn0"
+			    exclude-result-prefixes="xs fn0" version="3.0">
+  
+  <!-- Author: mukulg@apache.org -->
+  
+  <!-- use with test2.xml -->
+    
+  <!-- An XSL stylesheet test case, to test an XSL element xsl:function.
+       Using a rudimentary maths problem for this use case. 
+  -->				
+  
+  <xsl:output method="xml" indent="yes"/>
+  
+  <xsl:template match="/info">
+     <xsl:copy-of select="fn0:getDivPoint((point[1]/x, point[1]/y), (point[2]/x, point[2]/y), (ratio/m1, ratio/m2))"/>
+  </xsl:template>
+  
+  <!-- An XSL function definition, to find division point of 
+       a line-segment in the ratio m1:m2. -->
+  <xsl:function name="fn0:getDivPoint" as="element(divPoint)">
+     <xsl:param name="p1" as="xs:integer*"/>
+	 <xsl:param name="p2" as="xs:integer*"/>
+	 <xsl:param name="ratio" as="xs:positiveInteger*"/>
+	 <xsl:variable name="x1" select="$p1[1]" as="xs:integer"/>
+	 <xsl:variable name="y1" select="$p1[2]" as="xs:integer"/>
+	 <xsl:variable name="x2" select="$p2[1]" as="xs:integer"/>
+	 <xsl:variable name="y2" select="$p2[2]" as="xs:integer"/>
+	 <xsl:variable name="m1" select="$ratio[1]" as="xs:positiveInteger"/>
+	 <xsl:variable name="m2" select="$ratio[2]" as="xs:positiveInteger"/>
+	 <divPoint>
+	   <x><xsl:value-of select="($m2*$x1 + $m1*$x2) div ($m1 + $m2)"/></x>
+	   <y><xsl:value-of select="($m2*$y1 + $m1*$y2) div ($m1 + $m2)"/></y>
+	 </divPoint>	 
+  </xsl:function>
+  
+  <!--
+      * 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>
diff --git a/tests/xsl_function/test21.xsl b/tests/xsl_function/test21.xsl
new file mode 100644
index 000000000..f2c95070f
--- /dev/null
+++ b/tests/xsl_function/test21.xsl
@@ -0,0 +1,53 @@
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"			    
+			    xmlns:xs="http://www.w3.org/2001/XMLSchema"
+				xmlns:fn0="http://fn0"
+			    exclude-result-prefixes="xs fn0" version="3.0">
+			    
+  <!-- Author: mukulg@apache.org -->
+    
+  <!-- An XSL stylesheet test case, to test an XSL element xsl:function.
+       Using a rudimentary maths problem for this use case.
+  -->			    
+  
+  <xsl:output method="xml" indent="yes"/>
+  
+  <xsl:template match="/">
+     <xsl:copy-of select="fn0:triangleArea((1,3),(2,-5),(-8,4))"/>
+  </xsl:template>
+  
+  <!-- An XSL function definition, to find area of a triangle 
+       whose vertex co-ordinates are specified. -->
+  <xsl:function name="fn0:triangleArea" as="element(area)">
+     <xsl:param name="p1" as="xs:integer*"/>
+	 <xsl:param name="p2" as="xs:integer*"/>
+	 <xsl:param name="p3" as="xs:integer*"/>
+	 <xsl:variable name="x1" select="$p1[1]" as="xs:integer"/>
+	 <xsl:variable name="y1" select="$p1[2]" as="xs:integer"/>
+	 <xsl:variable name="x2" select="$p2[1]" as="xs:integer"/>
+	 <xsl:variable name="y2" select="$p2[2]" as="xs:integer"/>
+	 <xsl:variable name="x3" select="$p3[1]" as="xs:integer"/>
+	 <xsl:variable name="y3" select="$p3[2]" as="xs:integer"/>
+	 <area>
+	   <xsl:value-of select="abs(0.5 * (($x1 - $x3)*($y2 - $y3) - ($x2 - $x3)*($y1 - $y3)))"/>
+	 </area>	 
+  </xsl:function>
+  
+  <!--
+      * 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>
diff --git a/tests/xsl_function/test22.xsl b/tests/xsl_function/test22.xsl
new file mode 100644
index 000000000..e9d17c0e6
--- /dev/null
+++ b/tests/xsl_function/test22.xsl
@@ -0,0 +1,55 @@
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"			    
+			    xmlns:xs="http://www.w3.org/2001/XMLSchema"
+				xmlns:fn0="http://fn0"
+			    exclude-result-prefixes="xs fn0" version="3.0">
+  
+  <!-- Author: mukulg@apache.org -->
+  
+  <!-- use with test3.xml -->
+    
+  <!-- An XSL stylesheet test case, to test an XSL element xsl:function.
+       Using a rudimentary maths problem for this use case.
+  -->	
+  
+  <xsl:output method="xml" indent="yes"/>
+  
+  <xsl:template match="/info">
+     <xsl:copy-of select="fn0:triangleArea((point[1]/x, point[1]/y), (point[2]/x, point[2]/y), (point[3]/x, point[3]/y))"/>
+  </xsl:template>
+  
+  <!-- An XSL function definition, to find area of a triangle 
+       whose vertex co-ordinates are specified. -->
+  <xsl:function name="fn0:triangleArea" as="element(area)">
+     <xsl:param name="p1" as="xs:integer*"/>
+	 <xsl:param name="p2" as="xs:integer*"/>
+	 <xsl:param name="p3" as="xs:integer*"/>
+	 <xsl:variable name="x1" select="$p1[1]" as="xs:integer"/>
+	 <xsl:variable name="y1" select="$p1[2]" as="xs:integer"/>
+	 <xsl:variable name="x2" select="$p2[1]" as="xs:integer"/>
+	 <xsl:variable name="y2" select="$p2[2]" as="xs:integer"/>
+	 <xsl:variable name="x3" select="$p3[1]" as="xs:integer"/>
+	 <xsl:variable name="y3" select="$p3[2]" as="xs:integer"/>
+	 <area>
+	   <xsl:value-of select="abs(0.5 * (($x1 - $x3)*($y2 - $y3) - ($x2 - $x3)*($y1 - $y3)))"/>
+	 </area>	 
+  </xsl:function>
+  
+  <!--
+      * 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>
diff --git a/tests/xsl_function/test23.xsl b/tests/xsl_function/test23.xsl
new file mode 100644
index 000000000..c234e39a6
--- /dev/null
+++ b/tests/xsl_function/test23.xsl
@@ -0,0 +1,53 @@
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"			    
+			    xmlns:xs="http://www.w3.org/2001/XMLSchema"
+				xmlns:fn="http://www.w3.org/2005/xpath-functions"
+				xmlns:fn0="http://fn0"
+			    exclude-result-prefixes="xs fn fn0" version="3.0">
+			    
+  <!-- Author: mukulg@apache.org -->
+    
+  <!-- An XSL stylesheet test case, to test an XSL element xsl:function. 
+       This stylesheet gets its input data from a JSON document. Using a rudimentary 
+       maths problem for this use case.
+  -->			    
+  
+  <xsl:output method="xml" indent="yes"/>
+  
+  <xsl:template match="/">
+    <xsl:copy-of select="fn0:triangleArea(json-to-xml(unparsed-text('info1.json')))"/>
+  </xsl:template>
+  
+  <!-- An XSL function definition, to find area of a triangle 
+       whose vertex co-ordinates are specified. -->
+  <xsl:function name="fn0:triangleArea" as="element(area)">
+     <xsl:param name="var1" as="document-node()"/>
+	 <xsl:variable name="x1" select="$var1/fn:array/fn:map[1]/fn:number[@key eq 'x']" as="xs:integer"/>
+	 <xsl:variable name="y1" select="$var1/fn:array/fn:map[1]/fn:number[@key eq 'y']" as="xs:integer"/>
+	 <xsl:variable name="x2" select="$var1/fn:array/fn:map[2]/fn:number[@key eq 'x']" as="xs:integer"/>
+	 <xsl:variable name="y2" select="$var1/fn:array/fn:map[2]/fn:number[@key eq 'y']" as="xs:integer"/>
+	 <xsl:variable name="x3" select="$var1/fn:array/fn:map[3]/fn:number[@key eq 'x']" as="xs:integer"/>
+	 <xsl:variable name="y3" select="$var1/fn:array/fn:map[3]/fn:number[@key eq 'y']" as="xs:integer"/>	 	 
+	 <area>
+	   <xsl:value-of select="abs(0.5 * (($x1 - $x3)*($y2 - $y3) - ($x2 - $x3)*($y1 - $y3)))"/>
+	 </area>
+  </xsl:function>
+  
+  <!--
+      * 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>
diff --git a/tests/xsl_function/test3.xml b/tests/xsl_function/test3.xml
new file mode 100644
index 000000000..9bb6e8111
--- /dev/null
+++ b/tests/xsl_function/test3.xml
@@ -0,0 +1,14 @@
+<info>
+  <point>
+    <x>1</x>
+	<y>3</y>
+  </point>
+  <point>
+    <x>2</x>
+	<y>-5</y>
+  </point>
+  <point>
+    <x>-8</x>
+	<y>4</y>
+  </point>
+</info>


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