This chapter provides descriptions of the XQuery numeric operators available in the mapper functionality of WebLogic Workshop. You use the mapper functionality to generate queries and to edit these queries to add invocations to these provided XQuery operators. To learn more, see Invoking Functions or Operators in a Query.
In addition to the XQuery functions and operators available in the mapper functionality, a larger set functions and operators is provided. You can manually add invocations to these functions and operators to queries in the Source View of the mapper functionality. For a list of these additional functions and operators, see the XQuery 1.0 and XPath 2.0 Functions and Operators - W3C Working Draft 16 August 2002 available from the W3C Web site at the following URL:
http://www.w3.org/TR/2002/WD-xquery-operators-20020816
This section lists the numeric operators available from the mapper functionality:
Add $decimal-var1
to $decimal-var2
. The + operator invokes the decimal-add
operator.
op:
decimal-add(
xs:
decimal $decimal-var1, xs:decimal $decimal-var2) —> xs:decimal
Returns the decimal value of adding $decimal-var1
to $decimal-var2.
Invoking decimal-add("1.1","2.2")
returns the decimal value 3.3 as shown in the following example query:
<decimal-add>{op:decimal-add("1.1","2.2")}</decimal-add>
The preceding query generates the following result:
<decimal-add>3.3</decimal-add>
W3C decimal data type description.
W3C numeric-add operator description.
Add $float-var1
to $float-var2
. The + operator invokes the float-add
operator.
op:
float-add
(
xs:
float $float-var1, xs:float $float-var2) —> xs:float
Returns the float value of adding $float-var1
to $float-var2
.
Invoking float-add("1.0","2.0")
returns the floating point value: 3.0 as shown in the following example query:
<float-add>{op:float-add("1.0","2.0")}</float-add>
The preceding query generates the following result:
W3C float data type description.
W3C numeric-add operator description.
Add $double-var1
to $double-var2
. The + operator invokes the double-add operator.
op:
double-add(
xs:
double $double-var1, xs:double $double-var2) —> xs:double
Returns the double value of adding $double-var1
to $double-var2
.
Invoking double-add("1.0","2.0")
returns the double precision floating point value: 3.0 as shown in the following example query:
<double-add>{op:double-add("1.0","2.0")}</double-add>
The preceding query generates the following result:
W3C double data type description.
W3C numeric-add operator description.
Subtracts $decimal-var2
from $decimal-var1
. The - operator invokes the decimal-subtract operator.
op:
decimal-subtract
(xs:
decimal $decimal-var1, xs:decimal $decimal-var2) —> xs:decimal
Returns the decimal value of subtracting $decimal-var2
from $decimal-var1
.
Invoking decimal-subtract("2.2","1.1")
returns the decimal value 1.1 as shown in the following example query:
<decimal-subtract>{op:decimal-subtract("2.2","1.1")}</decimal-subtract>
The preceding query generates the following result:
<decimal-subtract>1.1</decimal-subtract>
W3C decimal data type description.
W3C numeric-subtract operator description.
Subtracts $float-var2
from $float-var1
. The - operator invokes the float-subtract operator.
op:
float-subtract(
xs:
float $float-var1, xs:float $float-var2) —> xs:float
Returns the floating point value of subtracting $float-var2
from $float-var1
.
Invoking float-subtract("2.2","1.1")
returns the floating point value: 1.1 as shown in the following example query:
<float-subtract>{op:float-subtract("2.2","1.1")}</float-subtract>
The preceding query generates the following result:
<float-subtract>1.1</float-subtract>
W3C float data type description.
W3C numeric-subtract operator description.
Subtracts $double-var2
from $double-var1
. The - operator invokes the double-subtract operator.
op:
double-subtract(
op:
double $double-var1, op:double $double-var2) —> xs:double
Returns the double precision (64 bit) floating point value of subtracting $double-var2
from $double-var1
.
Invoking double-subtract("2.2","1.1") returns the double precision (64 bit) floating point value: 1.1 as shown in the following example query:
<double-subtract>{op:double-subtract("2.2","1.1")}</double-subtract>
The preceding query generates the following result:
<double-subtract>1.1</double-subtract>
W3C double data type description.
W3C numeric-subtract operator description.
Multiplies $decimal-var1
by $decimal-var2
. The * operator invokes the decimal-multiply operator.
op:
decimal-multiply(
xs:
decimal $decimal-var1,xs:decimal $decimal-var2) —> xs:decimal
Returns the decimal value of multiplying $decimal-var1
by $decimal-var2
.
Invoking decimal-multiply("2.0","1.0")
returns the decimal value: 2 as shown in the following example query:
<decimal-multiply>{op:decimal-multiply("2.0","1.0")}</decimal-multiply>
The preceding query generates the following result:
<decimal-multiply>2</decimal-multiply>
W3C decimal data type description.
W3C numeric-multiply operator description.
Multiplies $float-var1
by $float-var2
. The * operator invokes the float-multiply operator.
op:
float-multiply(
op:
float $float-var1, xs:float $float-var2) —> xs:float
Returns the 32 bit floating point value of multiplying $float-var1
by $float-var2
.
Invoking float-multiply("2.0","3.0")
returns the floating point value: 6.0 as shown in the following example query:
<float-multiply>{op:float-multiply("2.0","3.0")}</float-multiply>
The preceding query generates the following result:
<float-multiply>6.0</float-multiply>
W3C float data type description.
W3C numeric-multiply operator description.
Multiplies $double-var1
by $double-var2
. The * operator invokes the double-multiply operator.
op:
double-multiply
(
xs:
double $double-var1, xs:double $double-var2) —> xs:double
Returns the double precision (64 bit) floating point value of multiplying $double-var1
by $double-var2
.
Invoking double-multiply("2.0","3.0")
returns the double precision floating point value: 6.0 as shown in the following example query:
<double-multiply>{op:double-multiply("2.0","3.0")}</double-multiply>
The preceding query generates the following result:
<double-multiply>6.0</double-multiply>
W3C double data type description.
W3C numeric-multiply operator description.
Divides $decimal-var1
by $decimal-var2
. The div operator invokes the decimal-divide operator.
If the value of $decimal-var2
is equal to zero, the TransformException exception is raised with the RT_DIV_ZERO fault code. The following error message is displayed in the mapper:
Error occurred while executing XQuery: division by zero
op:
decimal-divide
(xs:
decimal $decimal-var1
, xs:
$decimal-var2
) —> xs:decimal
Returns the decimal value of dividing $decimal-var1
by $decimal-var2
.
Invoking decimal-divide("2.2","1.1")
returns the decimal value 2 as shown in the following example query:
<decimal-divide>{op:decimal-divide("2.2","1.1")}</decimal-divide>
The preceding query generates the following result:
<decimal-divide>2.0</decimal-divide>
Invoking decimal-divide("2.2","0")
throws the TransformException exception with the RT_DIV_ZERO fault code as shown in the following example query:
<decimal-divide>{op:decimal-divide("2.2","0")}</decimal-divide>
The following error message is displayed in the mapper:
Error occurred while executing XQuery: division by zero
W3C decimal data type description.
W3C numeric-divide operator description.
Divides $float-var1
by $float-var2
. The div operator invokes the float-divide operator .
If the value of $float-var2
is equal to zero, the value of Infinity is returned. To learn more see Divide by Zero.
op:
float-divide(
xs:
float $float-var1, xs:float $float-var2) —>xs:float
Returns the floating point value of dividing $float-var1
by $float-var2
.
Invoking float-divide("4.4","2.2")
returns the floating point value of 2.0 as shown in the following example query:
<float-divide>{op:float-divide("4.4","2.2")}</float-divide>
The preceding query generates the following result:
<float-divide>2.0</float-divide>
Invoking float-divide("2.2","0")
returns the Infinity value as shown in the following example query:
<float-divide>{op:float-divide("2.2","0")}</float-divide>
The preceding query generates the following result:
<float-divide>Infinity</float-divide>
To learn more see the IEEE Standard for Binary Floating-Point Arthimetic.
W3C float data type description.
W3C numeric-divide operator description.
IEEE Standard for Binary Floating-Point Arthimetic.
Divides $double-var1
by $double-var2
. The div operator invokes the double-divide operator.
If the value of $double-var2
is equal to zero, the value of Infinity is returned. To learn more see Divide by Zero.
op:
double-divide(xs:
double $double-var1, xs:double $double-var2) —> xs:double
Returns the double precision floating point value of dividing $double-var1
by $double-var2
.
Invoking double-divide("4.4","2.2")
returns the double precision floating point value of 2.0 as shown in the following example query:
<double-divide>{op:double-divide("4.4","2.2")}</double-divide>
The preceding query generates the following result:
<double-divide>2.0</double-divide>
Invoking double-divide("2.2","0")
returns the Infinity value as shown in the following example query:
<double-divide>{op:double-divide("2.2","0")}</double-divide>
The preceding query generates the following result:
<double-divide>Infinity</double-divide>
To learn more see the IEEE Standard for Binary Floating-Point Arthimetic.
W3C double data type description.
W3C numeric-divide operator description.
IEEE Standard for Binary Floating-Point Arthimetic.
Divides $integer-var1
by $integer-var2
and returns the resulting integer. If $integer-var2
is not divided evenly by $integer-var1
, the remainder is dropped—no rounding occurs. The idiv operator is invoked by the numeric-integer-divide operator.
If the value of $decimal-var2
is equal to zero, the TransformException exception is raised with the RT_DIV_ZERO fault code. The following error message is displayed in the mapper:
Error occurred while executing XQuery: division by zero
op:
numeric-integer-divide(
xs:
integer $integer-var1, xs:integer $double-var2) —> xs:integer
Returns the integer result of dividing $integer-var1
by $integer-var2
. If $integer-var2
is not divided evenly by $integer-var1
, the remainder is dropped—no rounding occurs.
Invoking op:numeric-integer-divide("4","2")
returns the integer: 2 as shown in the following example query:
op:numeric-integer-divide("4","2")
The preceding query generates the following result:
<numeric-integer-divide>2</numeric-integer-divide>
Note: | The integer: 4 is divided eventually by the integer: 2 with no remainder. |
Invoking op:numeric-integer-divide("5","2")
returns the integer: 2 as shown in the following example query:
op:numeric-integer-divide("5","2")
The preceding query generates the following result:
<numeric-integer-divide>2</numeric-integer-divide>
Note: | The remainder is discarded. |
Invoking op:numeric-integer-divide("2","0")
throws the TransformException exception with the RT_DIV_ZERO fault code as shown in the following example query:
op:numeric-integer-divide("2","0")
The following error message is displayed in the mapper:
Error occurred while executing XQuery: division by zero
W3C integer data type description.
W3C numeric-integer-divide operator description.
Return the remainder of dividing $decimal-var1
by $decimal-var2
. The mod operator invokes the decimal-mod operator.
If the value of $decimal-var2
is equal to zero, the TransformException exception is raised with the RT_DIV_ZERO fault code. The following error message is displayed in the mapper:
Error occurred while executing XQuery: division by zero
op:
decimal-mod
(xs:
decimal $decimal-var1, xs:decimal $decimal-var2) —>xs:decimal
Returns the remainder of dividing $decimal-var1
by $decimal-var2
.
Invoking decimal-mod("2.1","2.0")
returns the decimal value .1 because 2.1 divided by 2.0 results in 1 with the remainder: .1. The remainder: .1 is returned as shown in the following example query:
<decimal-mod>{op:decimal-mod("2.1","2.0")}</decimal-mod>
The preceding query generates the following result:
<decimal-mod>0.1</decimal-mod>
Invoking decimal-mod("2.2","0")
throws the TransformException exception with the RT_DIV_ZERO fault code as shown in the following example query:
<decimal-mod>{op:decimal-mod("2.2","0")}</decimal-mod>
The following error message is displayed in the mapper:
Error occurred while executing XQuery: division by zero
W3C decimal data type description.
W3C numeric-mod operator description.
Return the remainder of dividing $float-var1
by $float-var2
. The mod operator invokes the float-mod operator.
To learn more about using this operator with NaN, positive infinity, or negative infinity operands, see the W3C numeric-mod operator description.
op:
float-mod(
xs:
float $float-var1, xs:float $float-var2) —> xs:float
Returns the remainder of dividing $float-var1
by $float-var2
.
Invoking float-mod("1.25","1.0")
returns the floating point value: .25 because 1.25 divided by 1.0 results in 1 with the remainder: .25. The remainder: .25 is returned as shown in the following example query:
<float-mod>{op:float-mod("1.25","1.0")}</float-mod>
The preceding query generates the following result:
Invoking float-mod("2.2","0")
returns a NaN (Not a Number) value as shown in the following example query:
<float-mod>{op:float-mod("2.2","0")}</float-mod>
The preceding query generates the following result:
W3C float data type description.
W3C numeric-mod operator description.
Return the remainder of dividing $double-var1
by $double-var2
. The mod operator invokes the double-mod operator.
To learn more about using this operator with NaN, positive infinity, or negative infinity operands, see the W3C numeric-mod operator description.
op:
double-mod(
xs:
double $double-var1, xs:double $double-var2) —> xs:double
Returns the remainder of dividing $double-var1
by $double-var2
.
Invoking double-mod("1.25","1.0")
returns the double precision (64 bit) floating point value: .25
because 1.25
divided by 1.0
results in 1 with the remainder: .25
. The remainder: .25 is returned as shown in the following example query:
<double-mod>{op:double-mod("1.25","1.0")}</double-mod>
The preceding query generates the following result:
Invoking double-mod("2.2","0")
returns a NaN value as shown in the following example query:
<double-mod>{op:double-mod("2.2","0")}</double-mod>
The preceding query generates the following result:
W3C double data type description.
W3C numeric-mod operator description.