Converts $string-var (a string) to an integer value.
If the value of $string-var is greater than 9,223,372,036,854,775,807 or less than -9,223,372,036,854,775,808, the TransformException exception is raised with the SYS_LONG_OVERFLOW fault code. The following error message is displayed in the mapper:
Error occurred while executing XQuery: BigDecimal -> Long overflow!
Note: For performance reasons, the integer supported by this XQuery engine is equivalent to a Java long, which is smaller then the W3C XML Schema integer, which has an arbitrary length. To learn more, see the integer description.
Note: The value $string-var must be specified without commas as shown in the following example invocation:
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.
To learn more about using fault codes, see Getting the TransformException Fault Code Programmatically.
xs:integer(xs:string $string-var) —> xs:integer
Represents the string to convert to an integer value. |
Returns an integer value of $string-var.
Invoking integer("10402") returns the integer value 10402 as shown in the following example query:
<integer>{xs:integer("10402")}</integer>
The preceding query generates the following result:
<integer>10402</integer>
Invoking integer("104.0") outputs an error because the decimal point is not allowed in the argument.
For example, the following example query:
<integer>{xs:integer("104.0")}</integer>
Error occurred while executing XQuery: Could not cast "104.0" to type [integer@http://www.w3.org/2001/XMLSchema]
Invoking integer("foo") outputs an error because "foo" is not a number.
For example, the following example query:
<integer>{xs:decimal("foo")}</integer>
Error occurred while executing XQuery: Could not cast "foo" to type [integer@http://www.w3.org/2001/XMLSchema]
Invoking integer(()) returns an empty sequence. The empty sequence is a sequence containing zero items (), which is similar to null in SQL.
For example, the following example query:
<integer>{xs:integer(())}</integer>
The preceding query generates the following result:
<integer/>
An integer value in this XQuery engine has a maximum size of 9,223,372,036,854,775,807 and a minimum size of -9,223,372,036,854,775,808. For performance reasons, the integer supported by this XQuery engine is equivalent to a Java long, which is smaller then the W3C XML Schema integer, which has an arbitrary length.
integer data type description