![]() ![]() ![]() ![]() ![]() ![]() |
This chapter provides descriptions of the XQuery duration 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 duration operators available from the mapper functionality:
Adds $yearMonthDuration-var1
to $yearMonthDuration-var2
.
op:
add-yearMonthDurations
(xf:
yearMonthDuration $yearMonthDuration-var1, xf: yearMonthDuration $yearMonthDuration-var2) —> xf: yearMonthDuration
Returns the yearMonthDuration value of adding $yearMonthDuration-var1
to $yearMonthDuration-var2
.
The following example query adds a yearMonthDuration value equal to 1 year and 2 months to a yearMonthDuration value equal to 2 years and 11 months as shown in the following query:
op:add-yearMonthDurations(xf:yearMonthDuration("P1Y2M"), xf:yearMonthDuration("P2Y11M"))
The resulting yearMonthDuration value of 4 years and 1 month is returned as shown in the following result:
<yearMonthDuration>P4Y1M</yearMonthDuration>
W3C add-yearMonthDurations operator description.
W3C yearMonthDuration description.
xf: yearMonthDuration constructor description.
Subtracts the value of $yearMonthDuration-var2
from $yearMonthDuration-var1
.
op:
subtract-yearMonthDurations (
xf:
yearMonthDuration $yearMonthDuration-var1, xf: yearMonthDuration $yearMonthDuration-var2) —> xf:yearMonthDuration
Returns the yearMonthDuration value of subtracting $yearMonthDuration-var2
from $yearMonthDuration-var1
.
The following example query subtracts a yearMonthDuration value equal to 1 year and 1 month from a yearMonthDuration value equal to 3 years and 3 months as shown in the following query:
op:subtract-yearMonthDurations(xf:yearMonthDuration("P3Y3M"), xf:yearMonthDuration("P1Y1M"))
The resulting positive yearMonthDuration value of 2 years and 2 months is returned as shown in the following result:
The following example query subtracts a yearMonthDuration value equal to 3 years and 3 months from a yearMonthDuration value equal to 1 year and 1 month as shown in the following query:
op:subtract-yearMonthDurations(xf:yearMonthDuration("P1Y1M"), xf:yearMonthDuration("P3Y3M"))
The resulting negative yearMonthDuration value of 2 years and 2 months is returned as shown in the following result:
W3C subtract-yearMonthDurations operator description.
W3C yearMonthDuration description.
xf: yearMonthDuration constructor description.
Multiplies $yearMonthDuration-var
with $decimal-var
.
op:
multiply-yearMonthDuration
(xf:
yearMonthDuration $yearMonthDuration-var, xs:
decimal $decimal-var) —>xf:yearMonthDuration
Returns the yearMonthDuration value of dividing $yearMonthDuration-var
with $decimal-var
. The return value is rounded up to the nearest month and year as shown in the following example.
Multiplying the 1 year value of $yearMonthDuration-var
by 1.5 results in 1 year and 6 months. Multiplying the 1 month value of $yearMonthDuration-var
by 1.5 results in 1.5 months which is rounded up to 2 months. Adding 1 year and 6 months to 2 months results in a yearMonthDuration of 1 year and 8 months as shown in the following example query:
let $yearMonthDuration-var := xf:yearMonthDuration("P1Y1M")
let $mydur := op:multiply-yearMonthDuration($yearMonthDuration-var, $decimal-var)
<years>{xf:get-years-from-yearMonthDuration($mydur)}</years>
<months>{xf:get-months-from-yearMonthDuration($mydur)}</months>
The preceding query generates the following result:
Multiplying a 1 month yearMonthDuration by 0.49 results in 0.49 months which is rounded down to zero months as shown in the following example query:
let $yearMonthDuration-var := xf:yearMonthDuration("P1M")
let $mydur := op:multiply-yearMonthDuration($yearMonthDuration-var, $decimal-var)
<years>{xf:get-years-from-yearMonthDuration($mydur)}</years>
<months>{xf:get-months-from-yearMonthDuration($mydur)}</months>
The preceding query generates the following result:
W3C multiply-yearMonthDuration operator description.
W3C yearMonthDuration description.
xf: yearMonthDuration constructor description.
Divides $yearMonthDuration-var
by $decimal-var
.
op:
divide-yearMonthDuration
(xf:
yearMonthDuration $yearMonthDuration-var, xs:decimal $decimal-var) —>xf:yearMonthDuration
Returns the yearMonthDuration value of dividing $yearMonthDuration-var
by $decimal-var
. The return value is rounded up to the nearest year and month as shown in following example.
Dividing the 1 year value of $yearMonthDuration-var
by 2.0 results in 6 months. Dividing the 1 month value of $yearMonthDuration-var
by 2.0 results in .5 months which is rounded up to 1 month. Adding 6 months to 1 month results in a yearMonthDuration of 7 months as shown in the following example query:
let $yearMonthDuration-var := xf:yearMonthDuration("P1Y1M")
let $mydur := op:divide-yearMonthDuration($yearMonthDuration-var, $decimal-var)
<years>{xf:get-years-from-yearMonthDuration($mydur)}</years>
<months>{xf:get-months-from-yearMonthDuration($mydur)}</months>
The preceding query generates the following result:
Dividing a 1 month yearMonthDuration by 2.04 results in 0.4901... months which is rounded down to zero months as shown in the following example query:
let $yearMonthDuration-var := xf:yearMonthDuration("P1M")
let $mydur := op:divide-yearMonthDuration($yearMonthDuration-var, $decimal-var)
<years>{xf:get-years-from-yearMonthDuration($mydur)}</years>
<months>{xf:get-months-from-yearMonthDuration($mydur)}</months>
The preceding query generates the following result:
W3C divide-yearMonthDuration operator description.
W3C yearMonthDurationdescription.
xf: yearMonthDuration constructor description.
Adds $dayTimeDuration-var1
to $dayTimeDuration-var2
.
op:
add-dayTimeDurations
(xf:
dayTimeDuration $dayTimeDuration-var1, xf: dayTimeDuration $dayTimeDuration-var2) —>xf:dayTimeDuration
Returns the dayTimeDuration value of adding $dayTimeDuration-var1
to $dayTimeDuration-var2
.
The following example query adds a dayTimeDuration value equal to 1 day, 2 hours, 30 minutes, and 5 seconds to a dayTimeDuration value equal to 31 minutes as shown in the following query:
op:add-dayTimeDurations(xf:dayTimeDuration("P1DT2H30M5S"), xf:dayTimeDuration("PT31M"))
The resulting dayTimeDuration value of 1 day, 3 hours, 1 minute, and 5 seconds is returned as shown in the following result:
<dayTimeDuration>P1DT3H1M5S</dayTimeDuration>
W3C add-dayTimeDurations operator description.
W3C dayTimeDuration description.
xf: dayTimeDuration constructor description.
Subtracts the value of $dayTimeDuration-var2
from $dayTimeDuration-var1
.
op:
subtract-dayTimeDurations
(xf:
dayTimeDuration$dayTimeDuration-var1, xf: dayTimeDuration $dayTimeDuration-var2) —>xf:dayTimeDuration
Returns the dayTimeDuration value of subtracting $dayTimeDuration-var2 from $dayTimeDuration-var1.
The following example query subtracts a dayTimeDuration value equal to 1 day and 1 minute from a dayTimeDuration value equal to 3 days, 3 hours, 3 minutes, and 3 seconds as shown in the following query:
op:subtract-dayTimeDurations(xf:dayTimeDuration("P3DT3H3M3S"), xf:dayTimeDuration("P1DT1M"))
The resulting positive dayTimeDuration value of 2 days, 3 hours, 2 minutes and 3 seconds is returned as shown in the following result:
<positive>P2DT3H2M3S</positive>
The following example query subtracts a dayTimeDuration value equal to 3 days, 3 hours, 3 minutes, and 3 seconds from a dayTimeDuration value equal to 1 day and 1 minute as shown in the following query:
op:subtract-dayTimeDurations(xf:dayTimeDuration("P1DT1M"), xf:dayTimeDuration("P3DT3H3M3S"))
The resulting negative dayTimeDuration value of 2 years and 2 months is returned as shown in the following result:
<negative>-P2DT3H2M3S</negative>
W3C subtract-dayTimeDurations operator description.
W3C dayTimeDuration description.
xf: dayTimeDuration constructor description.
Multiplies $dayTimeDuration-var
with $decimal-var
.
op
:multiply-dayTimeDuration(xf:
dayTimeDuration $dayTimeDuration-var,xs: decimal $decimal-var) —> xf:dayTimeDuration
Returns the dayTimeDuration value of dividing $dayTimeDuration-var
with $decimal-var
.
Multiplying the 1 day value of $dayTimeDuration-var
by 1.5 results in 1 day and 12 hours. Multiplying the 1 hour value of $dayTimeDuration-var
by 1.5 results in 1 hour and 30 minutes. Adding 1 day and 12 hours to 1 hour and 30 minutes results in a dayTimeDuration
of 1 day, 13 hours, and 30 minutes as shown in the following example query:
op:multiply-dayTimeDuration(xf:dayTimeDuration("P1DT1H"), 1.5)
The preceding query generates the following result:
W3C multiply-dayTimeDuration operator description.
W3C dayTimeDuration description.
xf: dayTimeDuration constructor description.
Divides $dayTimeDuration-var
by $decimal-var
.
op:
divide-dayTimeDuration(xf:
dayTimeDuration $dayTimeDuration-var, xs:decimal-var $decimal-var) —> xf:dayTimeDuration
Returns the dayTimeDuration value of dividing $dayTimeDuration-var
by $decimal-var
.
Dividing the 1 day value of $dayTimeDuration-var
by 2.0
results in 12 hours. Dividing the 1 hour value of $dayTimeDuration-var
by 2.0
results in 30 minutes. Adding these values together results in a dayTimeDuration of 12 hours and 30 minutes as shown in the following example query:
op:divide-dayTimeDuration(xf:dayTimeDuration("P1DT1H"), 2.0)
The preceding query generates the following result:
W3C divide-dayTimeDuration operator description.
W3C dayTimeDuration description.
xf: dayTimeDuration constructor description.
![]() ![]() ![]() |