[prev in list] [next in list] [prev in thread] [next in thread]
List: xalan-cvs
Subject: [xalan-java] branch xalan-j_xslt3.0 updated: committing minor improvements to support for xml schema
From: mukulg () apache ! org
Date: 2023-06-04 17:16:12
Message-ID: 168589897210.1503650.7323768684580739190 () gitbox2-he-fi ! apache ! org
[Download RAW message or body]
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 7f642afe committing minor improvements to support for xml schema data types \
xs:integer, xs:long and xs:int. the implementation of xpath 3.1 function fn:not, \
required minor enhancements to support these changes (these changes, have been \
committed as well). committing few new related working test cases as well. 7f642afe \
is described below
commit 7f642afe515fd49eb4c96b7254a148e33c438312
Author: Mukul Gandhi <gandhi.mukul@gmail.com>
AuthorDate: Sun Jun 4 22:45:46 2023 +0530
committing minor improvements to support for xml schema data types xs:integer, \
xs:long and xs:int. the implementation of xpath 3.1 function fn:not, required minor \
enhancements to support these changes (these changes, have been committed as well). \
committing few new related working test cases as well.
---
src/org/apache/xalan/templates/ElemVariable.java | 8 ++--
.../xalan/templates/XSConstructorFunctionUtil.java | 33 ++++++++++++++
src/org/apache/xpath/compiler/Keywords.java | 9 ++++
src/org/apache/xpath/functions/FuncNot.java | 24 ++++++++--
src/org/apache/xpath/objects/XObject.java | 39 +++++++++-------
src/org/apache/xpath/operations/Minus.java | 30 ++++++++++++-
src/org/apache/xpath/operations/Plus.java | 35 ++++++++++++++-
src/org/apache/xpath/xs/types/XSInt.java | 42 +++++++++++++++--
src/org/apache/xpath/xs/types/XSInteger.java | 52 ++++++++++++++++++++--
src/org/apache/xpath/xs/types/XSLong.java | 42 +++++++++++++++--
.../xalan/xpath3/XsConstructorFunctions.java | 30 +++++++++++++
tests/xs_constructor_functions/gold/test10.out | 7 +++
.../{test9.xsl => test10.xsl} | 14 +++---
.../{test9.xsl => test11.xsl} | 14 +++---
.../{test9.xsl => test12.xsl} | 14 +++---
tests/xs_constructor_functions/test1_b.xml | 9 ++++
tests/xs_constructor_functions/test9.xsl | 2 +-
17 files changed, 353 insertions(+), 51 deletions(-)
diff --git a/src/org/apache/xalan/templates/ElemVariable.java \
b/src/org/apache/xalan/templates/ElemVariable.java index 8b14015f..97ef6171 100644
--- a/src/org/apache/xalan/templates/ElemVariable.java
+++ b/src/org/apache/xalan/templates/ElemVariable.java
@@ -318,15 +318,15 @@ public class ElemVariable extends ElemTemplateElement
var.allowDetachToRelease(false);
- if (transformer.getDebug())
- transformer.getTraceManager().fireSelectedEvent(sourceNode, this,
- "select", m_selectPattern, var);
+ if (transformer.getDebug()) {
+ transformer.getTraceManager().fireSelectedEvent(sourceNode, this, \
"select", + \
m_selectPattern, var); + }
}
else if (null == getFirstChildElem()) {
var = XString.EMPTYSTRING;
}
else {
-
// Use result tree fragment.
// Global variables may be deferred (see XUnresolvedVariable) and hence
// need to be assigned to a different set of DTMs than local variables
diff --git a/src/org/apache/xalan/templates/XSConstructorFunctionUtil.java \
b/src/org/apache/xalan/templates/XSConstructorFunctionUtil.java index \
e43e7ab7..8f4911ee 100644
--- a/src/org/apache/xalan/templates/XSConstructorFunctionUtil.java
+++ b/src/org/apache/xalan/templates/XSConstructorFunctionUtil.java
@@ -30,6 +30,9 @@ import org.apache.xpath.xs.types.XSBoolean;
import org.apache.xpath.xs.types.XSDecimal;
import org.apache.xpath.xs.types.XSDouble;
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.xml.sax.SAXException;
/**
@@ -85,6 +88,36 @@ public class XSConstructorFunctionUtil {
ResultSequence rSeq = (new XSDouble()).constructor(argSequence);
evalResult = rSeq.item(0);
}
+ else if \
((Keywords.FUNC_XS_INTEGER).equals(funcExtFunction.getFunctionName())) { \
+ ResultSequence argSequence = new ResultSequence();
+ for (int idx = 0; idx < funcExtFunction.getArgCount(); idx++) {
+ XObject argVal = \
(funcExtFunction.getArg(idx)).execute(xctxt); + \
argSequence.add(new XSInteger(argVal.str())); + }
+
+ ResultSequence rSeq = (new \
XSInteger()).constructor(argSequence); + evalResult = \
rSeq.item(0); + }
+ else if \
((Keywords.FUNC_XS_LONG).equals(funcExtFunction.getFunctionName())) { \
+ ResultSequence argSequence = new ResultSequence();
+ for (int idx = 0; idx < funcExtFunction.getArgCount(); idx++) {
+ XObject argVal = \
(funcExtFunction.getArg(idx)).execute(xctxt); + \
argSequence.add(new XSLong(argVal.str())); + }
+
+ ResultSequence rSeq = (new XSLong()).constructor(argSequence);
+ evalResult = rSeq.item(0);
+ }
+ else if \
((Keywords.FUNC_XS_INT).equals(funcExtFunction.getFunctionName())) { \
+ ResultSequence argSequence = new ResultSequence();
+ for (int idx = 0; idx < funcExtFunction.getArgCount(); idx++) {
+ XObject argVal = \
(funcExtFunction.getArg(idx)).execute(xctxt); + \
argSequence.add(new XSInt(argVal.str())); + }
+
+ ResultSequence rSeq = (new XSInt()).constructor(argSequence);
+ evalResult = rSeq.item(0);
+ }
else if \
((Keywords.FUNC_BOOLEAN_STRING).equals(funcExtFunction.getFunctionName())) { \
ResultSequence argSequence = new ResultSequence();
for (int idx = 0; idx < funcExtFunction.getArgCount(); idx++) {
diff --git a/src/org/apache/xpath/compiler/Keywords.java \
b/src/org/apache/xpath/compiler/Keywords.java index 6b7a3ae9..fceac675 100644
--- a/src/org/apache/xpath/compiler/Keywords.java
+++ b/src/org/apache/xpath/compiler/Keywords.java
@@ -271,6 +271,15 @@ public class Keywords
/** xs:double data type string. */
public static final String FUNC_XS_DOUBLE = "double";
+
+ /** xs:integer data type string. */
+ public static final String FUNC_XS_INTEGER = "integer";
+
+ /** xs:long data type string. */
+ public static final String FUNC_XS_LONG = "long";
+
+ /** xs:int data type string. */
+ public static final String FUNC_XS_INT = "int";
static
{
diff --git a/src/org/apache/xpath/functions/FuncNot.java \
b/src/org/apache/xpath/functions/FuncNot.java index e05cb8ca..eff2f33d 100644
--- a/src/org/apache/xpath/functions/FuncNot.java
+++ b/src/org/apache/xpath/functions/FuncNot.java
@@ -20,12 +20,16 @@
*/
package org.apache.xpath.functions;
+import org.apache.xalan.templates.XSConstructorFunctionUtil;
import org.apache.xpath.XPathContext;
import org.apache.xpath.objects.XBoolean;
import org.apache.xpath.objects.XObject;
+import org.apache.xpath.operations.Operation;
+import org.xml.sax.SAXException;
/**
- * Execute the Not() function.
+ * Execute the not() function.
+ *
* @xsl.usage advanced
*/
public class FuncNot extends FunctionOneArg
@@ -33,8 +37,9 @@ public class FuncNot extends FunctionOneArg
static final long serialVersionUID = 7299699961076329790L;
/**
- * Execute the function. The function must return
+ * Execute the function. The function must return
* a valid object.
+ *
* @param xctxt The current execution context.
* @return A valid XObject.
*
@@ -42,6 +47,19 @@ public class FuncNot extends FunctionOneArg
*/
public XObject execute(XPathContext xctxt) throws \
javax.xml.transform.TransformerException {
- return m_arg0.execute(xctxt).bool() ? XBoolean.S_FALSE : XBoolean.S_TRUE;
+ if (m_arg0 instanceof Operation) {
+ try {
+ XObject result = \
XSConstructorFunctionUtil.processFuncExtFunctionOrXPathOpn( + \
xctxt, m_arg0); + return result.bool() ? XBoolean.S_FALSE : \
XBoolean.S_TRUE; + }
+ catch(SAXException ex) {
+ throw new javax.xml.transform.TransformerException(ex.getMessage()); \
+ }
+ }
+ else {
+ return m_arg0.execute(xctxt).bool() ? XBoolean.S_FALSE : XBoolean.S_TRUE;
+ }
}
+
}
diff --git a/src/org/apache/xpath/objects/XObject.java \
b/src/org/apache/xpath/objects/XObject.java index f96898e3..d9fe70de 100644
--- a/src/org/apache/xpath/objects/XObject.java
+++ b/src/org/apache/xpath/objects/XObject.java
@@ -37,6 +37,9 @@ import org.apache.xpath.xs.types.XSBoolean;
import org.apache.xpath.xs.types.XSDecimal;
import org.apache.xpath.xs.types.XSDouble;
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.w3c.dom.DocumentFragment;
import org.w3c.dom.NodeList;
import org.w3c.dom.traversal.NodeIterator;
@@ -46,6 +49,7 @@ import org.w3c.dom.traversal.NodeIterator;
* converting the object to various types, such as a string.
* This class acts as the base class to other XPath type objects,
* such as XString, and provides polymorphic casting capabilities.
+ *
* @xsl.usage general
*/
public class XObject extends Expression implements Serializable, Cloneable
@@ -640,29 +644,34 @@ public class XObject extends Expression implements \
Serializable, Cloneable return ((XSDecimal)this).equals((XSDecimal)obj2);
}
else if ((this instanceof XSFloat) && (obj2 instanceof XSFloat)) {
- return ((XSFloat)this).equals((XSFloat)obj2);
+ return ((XSFloat)this).equals((XSFloat)obj2);
}
else if ((this instanceof XSDouble) && (obj2 instanceof XSDouble)) {
- return ((XSDouble)this).equals((XSDouble)obj2);
+ return ((XSDouble)this).equals((XSDouble)obj2);
}
else if ((this instanceof XSBoolean) && (obj2 instanceof XSBoolean)) {
return ((XSBoolean)this).equals((XSBoolean)obj2);
}
-
- // In order to handle the 'all' semantics of
- // nodeset comparisons, we always call the
- // nodeset function.
- if (obj2.getType() == XObject.CLASS_NODESET)
- return obj2.equals(this);
-
- if (null != m_obj)
- {
- return m_obj.equals(obj2.m_obj);
+ else if ((this instanceof XSInteger) && (obj2 instanceof XSInteger)) {
+ return ((XSInteger)this).equals((XSInteger)obj2);
}
- else
- {
- return obj2.m_obj == null;
+ else if ((this instanceof XSLong) && (obj2 instanceof XSLong)) {
+ return ((XSLong)this).equals((XSLong)obj2);
+ }
+ else if ((this instanceof XSInt) && (obj2 instanceof XSInt)) {
+ return ((XSInt)this).equals((XSInt)obj2);
+ }
+
+ if (obj2.getType() == XObject.CLASS_NODESET) {
+ return obj2.equals(this);
+ }
+
+ if (m_obj != null) {
+ return m_obj.equals(obj2.m_obj);
}
+ else {
+ return obj2.m_obj == null;
+ }
}
/**
diff --git a/src/org/apache/xpath/operations/Minus.java \
b/src/org/apache/xpath/operations/Minus.java index 4874bb49..e4f015ca 100644
--- a/src/org/apache/xpath/operations/Minus.java
+++ b/src/org/apache/xpath/operations/Minus.java
@@ -20,11 +20,16 @@
*/
package org.apache.xpath.operations;
+import java.math.BigInteger;
+
import org.apache.xpath.XPathContext;
import org.apache.xpath.objects.XNumber;
import org.apache.xpath.objects.XObject;
import org.apache.xpath.xs.types.XSDecimal;
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;
/**
* The binary '-' operation expression executer.
@@ -49,6 +54,27 @@ public class Minus extends Operation
throws \
javax.xml.transform.TransformerException { XObject result = null;
+ if ((left instanceof XSInteger) && (right instanceof XSInteger)) {
+ BigInteger bigIntLeft = ((XSInteger)left).intValue();
+ BigInteger bigIntRight = ((XSInteger)right).intValue();
+
+ return new XSInteger(bigIntLeft.subtract(bigIntRight));
+ }
+
+ if ((left instanceof XSLong) && (right instanceof XSLong)) {
+ BigInteger bigIntLeft = ((XSLong)left).intValue();
+ BigInteger bigIntRight = ((XSLong)right).intValue();
+
+ return new XSLong(bigIntLeft.subtract(bigIntRight));
+ }
+
+ if ((left instanceof XSInt) && (right instanceof XSInt)) {
+ BigInteger bigIntLeft = ((XSInt)left).intValue();
+ BigInteger bigIntRight = ((XSInt)right).intValue();
+
+ return new XSInt(bigIntLeft.subtract(bigIntRight));
+ }
+
double leftArg = 0.0;
double rightArg = 0.0;
@@ -81,8 +107,8 @@ public class Minus extends Operation
}
if (isFloatLarg && isFloatRarg) {
- // currently, supporting XSFloat typed result, when both
- // operands are of type XSFloat.
+ // currently, supporting XSFloat typed result, when both operands
+ // are of type XSFloat.
result = new XSFloat(lArg - rArg);
return result;
}
diff --git a/src/org/apache/xpath/operations/Plus.java \
b/src/org/apache/xpath/operations/Plus.java index eb769d98..d2475512 100644
--- a/src/org/apache/xpath/operations/Plus.java
+++ b/src/org/apache/xpath/operations/Plus.java
@@ -20,11 +20,16 @@
*/
package org.apache.xpath.operations;
+import java.math.BigInteger;
+
import org.apache.xpath.XPathContext;
import org.apache.xpath.objects.XNumber;
import org.apache.xpath.objects.XObject;
import org.apache.xpath.xs.types.XSDecimal;
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;
/**
* The '+' operation expression executer.
@@ -48,6 +53,31 @@ public class Plus extends Operation
throws \
javax.xml.transform.TransformerException { XObject result = null;
+ if ((left instanceof XSInteger) && (right instanceof XSInteger)) {
+ BigInteger bigintLeft = ((XSInteger)left).intValue();
+ BigInteger bigintRight = ((XSInteger)right).intValue();
+
+ return new XSInteger(bigintLeft.add(bigintRight));
+ }
+
+ if ((left instanceof XSLong) && (right instanceof XSLong)) {
+ BigInteger bigintLeft = ((XSLong)left).intValue();
+ BigInteger bigintRight = ((XSLong)right).intValue();
+
+ // 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();
+ BigInteger bigintRight = ((XSInt)right).intValue();
+
+ // its possible that, result after addition is, not within value space of \
xs:int. + // handle this error. revisit
+ return new XSInt(bigintLeft.add(bigintRight));
+ }
+
double leftArg = 0.0;
double rightArg = 0.0;
@@ -80,9 +110,10 @@ public class Plus extends Operation
}
if (isFloatLarg && isFloatRarg) {
- // currently, supporting XSFloat typed result, when both
- // operands are of type XSFloat.
+ // currently, supporting XSFloat typed result, when both operands
+ // are of type XSFloat.
result = new XSFloat(lArg + rArg);
+
return result;
}
diff --git a/src/org/apache/xpath/xs/types/XSInt.java \
b/src/org/apache/xpath/xs/types/XSInt.java index 19e47959..72249bf6 100644
--- a/src/org/apache/xpath/xs/types/XSInt.java
+++ b/src/org/apache/xpath/xs/types/XSInt.java
@@ -34,6 +34,10 @@ public class XSInt extends XSLong {
private static final String XS_INT = "xs:int";
+ private static BigInteger MIN_INCLUSIVE = BigInteger.valueOf(-2147483648L);
+
+ private static BigInteger MAX_INCLUSIVE = BigInteger.valueOf(2147483647L);
+
/*
* Class constructor.
*/
@@ -48,10 +52,38 @@ public class XSInt extends XSLong {
super(val);
}
+ /*
+ * Class constructor.
+ */
+ public XSInt(String val) {
+ super(val);
+ }
+
@Override
- public ResultSequence constructor(ResultSequence arg) {
- // to do
- return null;
+ public ResultSequence constructor(ResultSequence arg) throws RuntimeException {
+ ResultSequence resultSeq = new ResultSequence();
+
+ if (arg.size() == 0) {
+ return resultSeq;
+ }
+
+ XSAnyType xsAnyType = (XSAnyType)arg.item(0);
+
+ try {
+ BigInteger bigInt = new BigInteger(xsAnyType.stringValue());
+
+ if (bigInt.compareTo(MIN_INCLUSIVE) == -1 ||
+ bigInt.compareTo(MAX_INCLUSIVE) == 1) {
+ throw new RuntimeException("An instance of type xs:int cannot be \
created. The numeric argument " + \
+ "'" + xsAnyType.stringValue() + "' provided is out of range for type xs:int."); + \
} +
+ resultSeq.add(new XSInt(bigInt));
+ } catch (NumberFormatException ex) {
+ throw new RuntimeException(ex.getMessage());
+ }
+
+ return resultSeq;
}
public String stringType() {
@@ -62,4 +94,8 @@ public class XSInt extends XSLong {
return "int";
}
+ public boolean equals(XSInt xsInt) {
+ return _value.equals(xsInt.intValue());
+ }
+
}
diff --git a/src/org/apache/xpath/xs/types/XSInteger.java \
b/src/org/apache/xpath/xs/types/XSInteger.java index 687d6868..0d207894 100644
--- a/src/org/apache/xpath/xs/types/XSInteger.java
+++ b/src/org/apache/xpath/xs/types/XSInteger.java
@@ -34,7 +34,9 @@ public class XSInteger extends XSDecimal {
private static final String XS_INTEGER = "xs:integer";
- private BigInteger _value;
+ // the underlying java.math.BigInteger value, representing
+ // this XML Schema datatype value.
+ protected BigInteger _value;
/*
* Class constructor.
@@ -88,8 +90,23 @@ public class XSInteger extends XSDecimal {
}
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);
+
+ try {
+ BigInteger bigInteger = castToInteger(xsAnyType);
+ resultSeq.add(new XSInteger(bigInteger));
+ } catch (NumberFormatException e) {
+ // to do
+ return null;
+ }
+
+ return resultSeq;
}
/**
@@ -110,5 +127,34 @@ public class XSInteger extends XSDecimal {
public void setInt(BigInteger val) {
_value = val;
}
+
+ /*
+ * Do a datatype cast, of a generic typed XML Schema value,
+ * to a java.math.BigInteger value.
+ */
+ private BigInteger castToInteger(XSAnyType xsAnyType) {
+
+ if (xsAnyType instanceof XSBoolean) {
+ if ((xsAnyType.stringValue()).equals("true")) {
+ return BigInteger.ONE;
+ }
+ else {
+ return BigInteger.ZERO;
+ }
+ }
+
+ if ((xsAnyType instanceof XSDecimal) || (xsAnyType instanceof XSFloat) ||
+ (xsAnyType instanceof XSDouble)) {
+ BigDecimal bigDecimal = new BigDecimal(xsAnyType.stringValue());
+
+ return bigDecimal.toBigInteger();
+ }
+
+ return new BigInteger(xsAnyType.stringValue());
+ }
+
+ public boolean equals(XSInteger xsInteger) {
+ return _value.equals(xsInteger.intValue());
+ }
}
diff --git a/src/org/apache/xpath/xs/types/XSLong.java \
b/src/org/apache/xpath/xs/types/XSLong.java index e241f950..482bfb1d 100644
--- a/src/org/apache/xpath/xs/types/XSLong.java
+++ b/src/org/apache/xpath/xs/types/XSLong.java
@@ -32,6 +32,10 @@ public class XSLong extends XSInteger {
private static final long serialVersionUID = -1030394161532436404L;
private static final String XS_LONG = "xs:long";
+
+ private static BigInteger MIN_INCLUSIVE = \
BigInteger.valueOf(-9223372036854775808L); +
+ private static BigInteger MAX_INCLUSIVE = \
BigInteger.valueOf(9223372036854775807L);
/*
* Class constructor.
@@ -47,10 +51,38 @@ public class XSLong extends XSInteger {
super(val);
}
+ /*
+ * Class constructor.
+ */
+ public XSLong(String val) {
+ super(val);
+ }
+
@Override
- public ResultSequence constructor(ResultSequence arg) {
- // to do
- return null;
+ public ResultSequence constructor(ResultSequence arg) throws RuntimeException {
+ ResultSequence resultSeq = new ResultSequence();
+
+ if (arg.size() == 0) {
+ return resultSeq;
+ }
+
+ XSAnyType xsAnyType = (XSAnyType)arg.item(0);
+
+ try {
+ BigInteger bigInt = new BigInteger(xsAnyType.stringValue());
+
+ if (bigInt.compareTo(MIN_INCLUSIVE) == -1 ||
+ bigInt.compareTo(MAX_INCLUSIVE) == 1) {
+ throw new RuntimeException("An instance of type xs:long cannot be \
created. The numeric argument " + \
+ "'" + xsAnyType.stringValue() + "' provided is out of range for type xs:long."); \
+ } +
+ resultSeq.add(new XSLong(bigInt));
+ } catch (NumberFormatException ex) {
+ throw new RuntimeException(ex.getMessage());
+ }
+
+ return resultSeq;
}
public String stringType() {
@@ -60,5 +92,9 @@ public class XSLong extends XSInteger {
public String typeName() {
return "long";
}
+
+ public boolean equals(XSLong xsLong) {
+ return _value.equals(xsLong.intValue());
+ }
}
diff --git a/tests/org/apache/xalan/xpath3/XsConstructorFunctions.java \
b/tests/org/apache/xalan/xpath3/XsConstructorFunctions.java index 0c819991..ef279847 \
100644
--- a/tests/org/apache/xalan/xpath3/XsConstructorFunctions.java
+++ b/tests/org/apache/xalan/xpath3/XsConstructorFunctions.java
@@ -137,5 +137,35 @@ public class XsConstructorFunctions extends \
XslTransformTestsUtil {
runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, \
null); }
+
+ @Test
+ public void XsConstructorFunctionsTest10() {
+ String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test1_b.xml";
+ String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test10.xsl";
+
+ String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test10.out"; \
+
+ runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, \
null); + }
+
+ @Test
+ public void XsConstructorFunctionsTest11() {
+ String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test1_b.xml";
+ String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test11.xsl";
+
+ String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test10.out"; \
+
+ runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, \
null); + }
+
+ @Test
+ public void XsConstructorFunctionsTest12() {
+ String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test1_b.xml";
+ String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test12.xsl";
+
+ String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test10.out"; \
+
+ runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, \
null); + }
}
diff --git a/tests/xs_constructor_functions/gold/test10.out \
b/tests/xs_constructor_functions/gold/test10.out new file mode 100644
index 00000000..56fcadef
--- /dev/null
+++ b/tests/xs_constructor_functions/gold/test10.out
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?><result>
+ <one>5</one>
+ <two>3</two>
+ <three>true</three>
+ <four>false</four>
+ <five>5</five>
+</result>
diff --git a/tests/xs_constructor_functions/test9.xsl \
b/tests/xs_constructor_functions/test10.xsl similarity index 67%
copy from tests/xs_constructor_functions/test9.xsl
copy to tests/xs_constructor_functions/test10.xsl
index f77f718c..2d0ef7e7 100644
--- a/tests/xs_constructor_functions/test9.xsl
+++ b/tests/xs_constructor_functions/test10.xsl
@@ -6,17 +6,21 @@
<!-- Author: mukulg@apache.org -->
- <!-- use with test1_a.xml -->
+ <!-- use with test1_b.xml -->
- <!-- this stylesheet, does few XPath arithmetic operations,
- involving xs:float types. -->
+ <!-- this stylesheet, does few XPath arithmetic and logical operations,
+ involving xs:integer type. -->
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/elem">
<result>
- <one><xsl:value-of select="xs:float(b) - xs:float(a)"/></one>
- <two><xsl:value-of select="xs:float(a) + xs:float(b)"/></two>
+ <one><xsl:value-of select="xs:integer(a) + xs:integer(b)"/></one>
+ <two><xsl:value-of select="xs:integer(d) - xs:integer(a)"/></two>
+ <three><xsl:value-of select="(xs:integer(d) - xs:integer(a)) = 3"/></three>
+ <four><xsl:value-of select="not((xs:integer(d) - xs:integer(a)) = \
3)"/></four> + <xsl:variable name="temp1" select="xs:integer(a) + \
xs:integer(b)"/> + <five><xsl:value-of select="$temp1"/></five>
</result>
</xsl:template>
diff --git a/tests/xs_constructor_functions/test9.xsl \
b/tests/xs_constructor_functions/test11.xsl similarity index 68%
copy from tests/xs_constructor_functions/test9.xsl
copy to tests/xs_constructor_functions/test11.xsl
index f77f718c..03955a4f 100644
--- a/tests/xs_constructor_functions/test9.xsl
+++ b/tests/xs_constructor_functions/test11.xsl
@@ -6,17 +6,21 @@
<!-- Author: mukulg@apache.org -->
- <!-- use with test1_a.xml -->
+ <!-- use with test1_b.xml -->
- <!-- this stylesheet, does few XPath arithmetic operations,
- involving xs:float types. -->
+ <!-- this stylesheet, does few XPath arithmetic and logical operations,
+ involving xs:long type. -->
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/elem">
<result>
- <one><xsl:value-of select="xs:float(b) - xs:float(a)"/></one>
- <two><xsl:value-of select="xs:float(a) + xs:float(b)"/></two>
+ <one><xsl:value-of select="xs:long(a) + xs:long(b)"/></one>
+ <two><xsl:value-of select="xs:long(d) - xs:long(a)"/></two>
+ <three><xsl:value-of select="(xs:long(d) - xs:long(a)) = 3"/></three>
+ <four><xsl:value-of select="not((xs:long(d) - xs:long(a)) = 3)"/></four>
+ <xsl:variable name="temp1" select="xs:long(a) + xs:long(b)"/>
+ <five><xsl:value-of select="$temp1"/></five>
</result>
</xsl:template>
diff --git a/tests/xs_constructor_functions/test9.xsl \
b/tests/xs_constructor_functions/test12.xsl similarity index 68%
copy from tests/xs_constructor_functions/test9.xsl
copy to tests/xs_constructor_functions/test12.xsl
index f77f718c..6d5c339e 100644
--- a/tests/xs_constructor_functions/test9.xsl
+++ b/tests/xs_constructor_functions/test12.xsl
@@ -6,17 +6,21 @@
<!-- Author: mukulg@apache.org -->
- <!-- use with test1_a.xml -->
+ <!-- use with test1_b.xml -->
- <!-- this stylesheet, does few XPath arithmetic operations,
- involving xs:float types. -->
+ <!-- this stylesheet, does few XPath arithmetic and logical operations,
+ involving xs:int type. -->
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/elem">
<result>
- <one><xsl:value-of select="xs:float(b) - xs:float(a)"/></one>
- <two><xsl:value-of select="xs:float(a) + xs:float(b)"/></two>
+ <one><xsl:value-of select="xs:int(a) + xs:int(b)"/></one>
+ <two><xsl:value-of select="xs:int(d) - xs:int(a)"/></two>
+ <three><xsl:value-of select="(xs:int(d) - xs:int(a)) = 3"/></three>
+ <four><xsl:value-of select="not((xs:int(d) - xs:int(a)) = 3)"/></four>
+ <xsl:variable name="temp1" select="xs:int(a) + xs:int(b)"/>
+ <five><xsl:value-of select="$temp1"/></five>
</result>
</xsl:template>
diff --git a/tests/xs_constructor_functions/test1_b.xml \
b/tests/xs_constructor_functions/test1_b.xml new file mode 100644
index 00000000..a27330f7
--- /dev/null
+++ b/tests/xs_constructor_functions/test1_b.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<elem>
+ <a>2</a>
+ <b>3</b>
+ <c>4</c>
+ <d>5</d>
+ <e>6</e>
+ <f>7</f>
+</elem>
\ No newline at end of file
diff --git a/tests/xs_constructor_functions/test9.xsl \
b/tests/xs_constructor_functions/test9.xsl index f77f718c..b8164c72 100644
--- a/tests/xs_constructor_functions/test9.xsl
+++ b/tests/xs_constructor_functions/test9.xsl
@@ -9,7 +9,7 @@
<!-- use with test1_a.xml -->
<!-- this stylesheet, does few XPath arithmetic operations,
- involving xs:float types. -->
+ involving xs:float type. -->
<xsl:output method="xml" indent="yes"/>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xalan.apache.org
For additional commands, e-mail: commits-help@xalan.apache.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic