Binary Module
This XQuery Module contains functions to process binary data, including extracting subparts, searching, basic binary operations and conversion between binary and structured forms.
This module is based on the EXPath Binary Module.
Contents
Conventions
All functions and errors in this module are assigned to the http://expath.org/ns/binary
namespace, which is statically bound to the bin
prefix.
Constants and Conversions
bin:hex
Signatures | bin:hex($in as xs:string?) as xs:base64Binary?
|
Summary | Returns the binary form of the set of octets written as a sequence of (ASCII) hex digits ([0-9A-Fa-f]).$in will be effectively zero-padded from the left to generate an integral number of octets, i.e. an even number of hexadecimal digits. If $in is an empty string, then the result will be an xs:base64Binary with no embedded data.Byte order in the result follows (per-octet) character order in the string. If the value of $in is the empty sequence, the function returns an empty sequence.
|
Errors | non-numeric-character : the input cannot be parsed as a hexadecimal number.
|
Examples | bin:hex('11223F4E') yields ESI/Tg== .xs:hexBinary(bin:hex('FF')) yields FF .
|
bin:bin
Signatures | bin:bin($in as xs:string?) as xs:base64Binary?
|
Summary | Returns the binary form of the set of octets written as a sequence of (8-wise) (ASCII) binary digits ([01]).$in will be effectively zero-padded from the left to generate an integral number of octets. If $in is an empty string, then the result will be an xs:base64Binary with no embedded data.Byte order in the result follows (per-octet) character order in the string. If the value of $in is the empty sequence, the function returns an empty sequence.
|
Errors | non-numeric-character : the input cannot be parsed as a binary number.
|
Examples | bin:bin('1101000111010101') yields 0dU= .xs:hexBinary(bin:bin('1000111010101')) yields 11D5 .
|
bin:octal
Signatures | bin:octal($in as xs:string?) as xs:base64Binary?
|
Summary | Returns the binary form of the set of octets written as a sequence of (ASCII) octal digits ([0-7]).$in will be effectively zero-padded from the left to generate an integral number of octets. If $in is an empty string, then the result will be an xs:base64Binary with no embedded data.Byte order in the result follows (per-octet) character order in the string. If the value of $in is the empty sequence, the function returns an empty sequence.
|
Errors | non-numeric-character : the input cannot be parsed as an octal number.
|
Examples | xs:hexBinary(bin:octal('11223047')) yields 252627 .
|
bin:to-octets
Signatures | bin:to-octets($in as xs:base64Binary) as xs:integer*
|
Summary | Returns binary data as a sequence of octets. If $in is a zero length binary data then the empty sequence is returned.Octets are returned as integers from 0 to 255. |
bin:from-octets
Signatures | bin:from-octets($in as xs:integer*) as xs:base64Binary
|
Summary | Converts a sequence of octets into binary data. Octets are integers from 0 to 255. If the value of $in is the empty sequence, the function returns zero-sized binary data.
|
Errors | octet-out-of-range : one of the octets lies outside the range 0 - 255.
|
...