Converts $string-var (a string) to a long 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 following error message is displayed:
Error occurred while executing XQuery: Could not cast "9223372036854775809" to type [long@http://www.w3.org/2001/XMLSchema]
Note: The value $string-var must be specified without commas as shown in the following example invocation:
If $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:long(xs:string $string-var) —> xs:long
Represents the string to convert to a long value. |
Returns the long value of $string-var.
Invoking long("10403")returns the integer value 10403 as shown in the following example query:
<long>{xs:long("10403")}</long>
The preceding query generates the following result:
<long>10403</long>
Invoking long("104.0") outputs an error because 104.0 is not a valid integer (decimal point is not allowed.)
For example, the following example query:
<long>{xs:long("104.0")}</long>
Produces the following error:
Error occurred while executing XQuery: Could not cast "104.0" to type [long@http://www.w3.org/2001/XMLSchema]
Invoking long("foo") outputs an error because "foo" is not a number.
For example, the following example query:
<long>{xs:long("foo")}</long>
Error occurred while executing XQuery: Could not cast "foo" to type [long@http://www.w3.org/2001/XMLSchema]
Invoking long(()) 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:
<long>{xs:long(())}</long>
The preceding query generates the following result:
<long/>
W3C long data type description