# xf:hexBinary

Converts $string-var (a string) to a hex-encoded arbitrary binary data.

If the value of $string-var is the empty sequence, the following error is displayed in the mapper:

Error occured while executing XQuery: Error loading the XQuery or XSLT for this method: Type error in function hexBinary invocation: expected type [string@http://www.w3.org/2001/XMLSchema], given type empty

The empty sequence is a sequence containing zero items (), which is similar to null in SQL.

### Signatures

xf:hexBinary(xs:string $string-var) —> xs:hexBinary

### Arguments

Data Type | Argument | Description
--- | --- | ---
xs:string | $string-var | Represents the string to be converted to a hex-encoded number.

### Returns

The base 64 binary value of $string-var.

### Examples

#### Simple

Invoking hexBinary("0FD7") returns the hex-encoded binary value of 0FD7, as shown in the following example query:

    <result>{xf:hexBinary("0FD7")}</result>

The preceding query generates the following result:

    <result>0FD7</result>

Note: The hex-encoded binary value of 0FD7 is equivalent to the decimal value of 4055 and the binary value of 111111010111.

Related Topics

W3C hexBinary data type description.