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