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