Converts $string-var (a string) to an int value.
If the value of $string-var is greater than 2,147,483,647 or less than -2,147,483,648, the following error is produced:
Error occurred while executing XQuery: Could not cast "2147483649" to type [int@http://www.w3.org/2001/XMLSchema]
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.
xs:int(xs:string $string-var) —> xs:int
Represents the string to convert to an int value. |
Returns the int value of $string-var.
Invoking int("10403")returns the integer value 10403 as shown in the following example query:
<int>{xs:int("10403")}</int>
The preceding query generates the following result:
<int>10403</int>
Invoking int("104.0")outputs an error because 104.0 not a valid integer (decimal point is not allowed.)
For example, the following example query:
<int>{xs:int("104.0")}</int>
Produces the following error:
Error occurred while executing XQuery: Could not cast "104.0" to type [int@http://www.w3.org/2001/XMLSchema]
Invoking int("foo")outputs an error because "foo" is not a number.
For example, the following example query:
<int>{xs:int("foo")}</int>
Produces the following error:
Error occurred while executing XQuery: Could not cast "foo" to type [int@http://www.w3.org/2001/XMLSchema]
Invoking int(()) 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:
<int>{xs:int(())}</int>
The preceding query generates the following result:
<int/>
W3C int data type description