XQuery Reference

     Previous  Next    Open TOC in new window    View as PDF - New Window  Get Adobe Reader - New Window
Content starts here

XQuery Numeric Function Reference

This chapter provides descriptions of the XQuery numeric functions 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 functions. 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 functions available from the Mapper tool:

 


bea-xf: format-number

Converts $double-var to a string using the format pattern specified by $string-var.

If the value of $double-var is the empty sequence, the following error is displayed in the mapper:

Error occurred while executing XQuery: Error loading the XQuery or XSLT for this method: Type error in function format-number invocation: expected type [double@http://www.w3.org/2001/XMLSchema], given type empty

The empty sequence is a sequence containing zero items (), which is similar to null in SQL.

Signatures

bea-xf:format-number(xs: double $double-var, xs: string $string-var) —> xs: string

Table 6-1 Arguments
Data Type
Argument
Description
xs:double
$double-var
Represents the double number to be converted to a string.
xs:string
$string-var
Represents the pattern string. The format of this pattern is specified by the JDK 1.4.1 DecimalFormat class.

Returns

Returns $double-var as a string based on the pattern specified by $string-var.

Examples
Add Comma And More Decimal Places

Invoking format-number(xs:double(10002.45), "#,###0.000#") returns the string 1,0002.450 as shown in the following example query:

<result>{bea-xf:format-number(xs:double(10002.45), "#,###0.000#")}</result>

The preceding query generates the following result:

<result>1,0002.450</result>

XQuery Compliance

Not a standard W3C XQuery function. This is a standard XSLT function.

Note: Only the two argument version of the standard XSLT function is supported.
Related Topics

W3C XSLT format-number function description.

JDK 1.4.1 DecimalFormat class description.

 


xf: floor

Rounds $double-var down to the next whole number.

If the value of $string-var is the empty sequence, the empty sequence is returned. The empty sequence is a sequence containing zero items (), which is similar to null in SQL.

Signatures

xf:floor(xs: double?$double-var) —> xs:double?

Table 6-2 Arguments
Data Type
Argument
Description
xs:double?
$double-var
Represents the double to round down.

Returns

Returns a double equal to $double-var rounded down to the next whole number.

Table 6-3 Examples
This Query . . .
Generates This Result . . .
<r>{xf:floor(xs:double("11.9"))}</r>
<r>11.0</r>
<r>{xf:floor(xs:double("11.5"))}</r>
<r>11.0</r>
<r>{xf:floor(xs:double("11.1"))}</r>
<r>11.0</r>
<r>{xf:floor(xs:double("-11.9"))}</r>
<r>-12.0</r>
<r>{xf:floor(xs:double("-11.5"))}</r>
<r>-12.0</r>
<r>{xf:floor(xs:double("-11.1"))}</r>
<r>-12.0</r>

Related Topics

W3C floor function description.

 


xf: ceiling

Rounds $double-var up to the next whole number.

If the value of $string-var is the empty sequence, the empty sequence is returned.The empty sequence is a sequence containing zero items (), which is similar to null in SQL.

Signatures

xf:ceiling(xs: double?$double-var) —> xs:double?

Table 6-4 Arguments
Data Type
Argument
Description
xs:double?
$double-var
Represents the double to round up.

Returns

Returns a double equal to $double-var rounded up to the next whole number.

Table 6-5 Examples
This Query . . .
Generates This Result . . .
<r>{xf:ceiling(xs:double("11.9"))}</r>
<r>12.0</r>
<r>{xf:ceiling(xs:double("11.5"))}</r>
<r>12.0</r>
<r>{xf:ceiling(xs:double("11.1"))}</r>
<r>12.0</r>
<r>{xf:ceiling(xs:double("-11.9"))}</r>
<r>-11.0</r>
<r>{xf:ceiling(xs:double("-11.5"))}</r>
<r>-11.0</r>
<r>{xf:ceiling(xs:double("-11.1"))}</r>
<r>-11.0</r>

Related Topics

W3C ceiling function description.

 


xf: round

Rounds $double-var to the nearest whole number.

If the value of $string-var is the empty sequence, the empty sequence is returned. The empty sequence is a sequence containing zero items (), which is similar to null in SQL.

Signatures

xf:round(xs: double?$double-var) —> xs:double?

Table 6-6 Arguments
Data Type
Argument
Description
xs:double?
$double-var
Represents the double to round.

Returns

Returns a double equal to $double-var rounded to the nearest whole number.

Table 6-7 Examples
This Query . . .
Generates This Result . . .
<r>{xf:round(xs:double("11.9"))}</r>
<r>12.0</r>
<r>{xf:round(xs:double("11.5"))}</r>
<r>12.0</r>
<r>{xf:round(xs:double("11.1"))}</r>
<r>11.0</r>
<r>{xf:round(xs:double("-11.9"))}</r>
<r>-12.0</r>
<r>{xf:round(xs:double("-11.5"))}</r>
<r>-11.0</r>
<r>{xf:round(xs:double("-11.1"))}</r>
<r>-11.0</r>

Related Topics

W3C round function description.


  Back to Top       Previous  Next